PHP Home

The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. This tutorial helps you to build your base with PHP. This PHP tutorial covers all the topics of PHP such as …

Read More »

PHP Pimcore Model User Role

Pimcore

The below code snippet is for list the user role details through role name. <?php namespace AppBundle\Controller; use Pimcore\Controller\FrontendController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class DemoController extends FrontendController { /** * @Route("/model-user-role") */ public function modelUserRoleAction() { $role = \Pimcore\Model\User\Role::getByName('Admin'); } }

Read More »

PHP Pimcore Model User

Pimcore

The below code snippet is for list the user details through user id. <?php namespace AppBundle\Controller; use Pimcore\Controller\FrontendController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class DemoController extends FrontendController { /** * @Route("/model-user") */ public function modeluserAction() { $user = \Pimcore\Model\User::getById(2); } }

Read More »

How to Call a Command from a Controller

Pimcore

This article covers how to use a console command directly from your controller. <?php namespace AppBundle\Controller; use Pimcore\Controller\FrontendController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class DemoController extends FrontendController { /** * @Route("/admin/runcommand", name="runcommand") * @param Request $request * @return \Symfony\Component\HttpFoundation\JsonResponse */ public function getImportVendor(Request $request) { $path = "php " . PIMCORE_PROJECT_ROOT …

Read More »

Install Assets in Symfony

The assets:install command is one of the trickiest things for Symfony newcomers. This command is used to install the web assets (CSS, JavaScript, images) for the production application. When executed without options, the command copies into web/ all the files found in the Resources/public/ directories of your application and bundles. …

Read More »

How can replace all images with the same name in the assets folder

Pimcore

Put the below function in your class file and run the static route. /** * @Route("/image") */ public function imageUploadAction() { $image = "/folder1/image.png"; //$image = "/folder2/image.png"; // Uncomment this path after upload first image, than the old image will be replaced $image_parts = pathinfo($image); $exist = \Pimcore\Model\Asset::getByPath('/' . $image_parts['filename'] …

Read More »

Upload image through Pimcore command in the asset folder

Pimcore

Create the command folder in the AppBundle folder. Than create the ImageUploadCommand.php /var/www/html/proj/src/AppBundle/Command/ImageUploadCommand.php <?php namespace AppBundle\Command; use Pimcore\Console\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use AppBundle\Service\UploadImage; class ImageUploadCommand extends AbstractCommand { protected function configure() { $this ->setName('imageupload:command') ->setDescription('Image upload command'); } protected function execute(InputInterface $input, OutputInterface $output) { $obj = …

Read More »