Home » PHP » Pimcore » How To Generate Pimcore Bundles?

How To Generate Pimcore Bundles?

Pimcore

To generate bundles the below commands can be use. The steps run on Pimcore 5. The details are below

# generate bundle interactively
$ bin/console pimcore:generate:bundle

# if the command is not available, make sure you are running the console in dev environment (see note below)
$ bin/console pimcore:generate:bundle --env=dev

# generate bundle with a given name and don't ask questions
$ bin/console pimcore:generate:bundle --namespace=Test1/Blog1Bundle --no-interaction

Step 1: Run the below command to generate bundle on the ubuntu terminal in the project directory. Here the namespace is Test1 and bundle name is Blog1Bundle.

bin/console pimcore:generate:bundle

Step 2: Run the below commands on the ubuntu terminal to list the bundle in the project directory. The Blog1Bundle is showing with disable mode.

bin/console pimcore:bundle:list

Step 3: Run the below commands on the ubuntu terminal to enable the bundle in the project directory. 

bin/console pimcore:bundle:enable Blog1Bundle

Step 4: Run the below command for directory permission.

sudo chmod 777 -R .

Bundle is installed and activated successfully. Let’s check the bundle and run the script on the browser. The details are below-

/var/www/html/pimcore/src/Test1/Blog1Bundle/Resources/config/pimcore/routing.yml

blog1:
    resource: "@Blog1Bundle/Controller/"
    type:     annotation
    prefix:   /
/var/www/html/pimcore/src/Test1/Blog1Bundle/Controller/DefaultController.php

<?php

namespace Test1\Blog1Bundle\Controller;

use Pimcore\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends FrontendController
{
    /**
     * @Route("/blog1")
     */
    public function indexAction(Request $request)
    {
        return new Response('Hello world from blog1');
    }
}

Run the url on the browser to check the script. i.e http://<base url>/blog1. It will display the text “Hello world from blog1”. It’s means everything is working fine.

Check Also

Pimcore

Top Pimcore 5 Interview Questions And Answers Part 1

1. How can we show the localizedfield data in Pimcore 5? The variables of the …

Leave a Reply

Your email address will not be published. Required fields are marked *