I'm getting trouble generating a new bundle siwth sensio/generator-bundle, symfony ^3.4, what i do is:
> symfony new calendar --version=^3.4
> cd calendar
> composer require sensio/generator-bundle
> php bin/console generate:bundle:
> planning on sharing this bundle: yes
> Bundle namespace: Nmateo/CalBundle
> Bundle name"NmateoCalBundle": [enter]
> Target Directory"src/": [enter]
> Configuration format"xml": [enter]
> symfony new calendar --version=^3.4
> cd calendar
> composer require sensio/generator-bundle
> php bin/console generate:bundle:
> planning on sharing this bundle: yes
> Bundle namespace: Nmateo/CalBundle
> Bundle name"NmateoCalBundle": [enter]
> Target Directory"src/": [enter]
> Configuration format"xml": [enter]
Then i get this message:
The command was not able to configure everything automatically.
You'll need to make the following changes manually.
-Edit the composer.json file and register the bundle namespace in the "autoload" section:-Edit /home/nmateo/Documents/calendar/src/Kernel.php and add the following bundle in the AppKernel::registerBundles() method:
new Nmateo\\CalBundle\\NmateoCalBundle(),
So i registered it in autoloader:
"autoload": {
"psr-4": {
"App\\": "src/",
"Nmateo\\CalBundle\\": "src/Nmateo/CalBundle/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/",
"Nmateo\\CalBundle\\": "src/Nmateo/CalBundle/"
}
},
and added new Nmateo CalBundle NmateoCalBundle to the end of registerBundles in Kernel.php:
public function registerBundles()
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class();
}
}
new Nmateo\CalBundle\NmateoCalBundle();
}
and do the composer dump-autoload:
Generated autoload files containing 0 classes
And then i start my server and got this error, i tried many times..:
EDIT: Sorry for the text in codes quote but the stackoverflow is giving me headaches since it dont want to publish my question it says: please place your code in code quotes buy all my code was already in codes quotes..
Read GitHub repository before use any bundle. This bundle can`t works well with Symfony 4.0
Symfony 3.4 is equal to LTS Symfony 4.0
Sensiolabs uses *.4th versions as feature-freeze version.
https://github.com/sensiolabs/SensioGeneratorBundle
"WARNING: This bundle does not support Symfony 4. It also does not support the new bundle-less directory structure as created by Symfony Flex. Use the Maker bundle instead."
Symfony 3.4 has an issue with generating a new bundle its a known issue, https://github.com/symfony/symfony-standard/issues/1098 to fix that change your code as below
"autoload": {
"psr-4": {
"": "src/"
}
What we did is that we specified in the composer that every new generated bundle will be imported from /src
To finish the procedure you'll need to run
composer dump-autoload
make sure you have the file composer.phar
or download it from here https://getcomposer.org/download/
hope it helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.