symfony / symfony

The Symfony PHP framework
https://symfony.com
MIT License
29.72k stars 9.45k forks source link

generate bundle autoload failed since symfony 3.3.5 in windows #23630

Closed adityarai closed 7 years ago

adityarai commented 7 years ago

Checking that the bundle is autoloaded FAILED

dorcyv commented 7 years ago

On Linux to:

 kipik@Anonymous-PC  ~/Documents/Perso  symfony new Test

 Downloading Symfony...

    5.8 MiB/5.8 MiB ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100%

 Preparing project...

 ✔  Symfony 3.3.5 was successfully installed. Now you can:

    * Change your current directory to /home/kipik/Documents/Perso/Test

    * Configure your application in app/config/parameters.yml file.

    * Run your application:
        1. Execute the php bin/console server:start command.
        2. Browse to the http://localhost:8000 URL.

    * Read the documentation at http://symfony.com/doc

 kipik@Anonymous-PC  ~/Documents/Perso  cd Test 
 kipik@Anonymous-PC  ~/Documents/Perso/Test  ls
README.md  app  bin  composer.json  composer.lock  phpunit.xml.dist  src  tests  var  vendor  web
 kipik@Anonymous-PC  ~/Documents/Perso/Test  ./bin/console generate:bundle

  Welcome to the Symfony bundle generator!  

Are you planning on sharing this bundle across multiple applications? [no]: 

Your application code must be written in bundles. This command helps
you generate them easily.

Give your bundle a descriptive name, like BlogBundle.
Bundle name: TestBundle

Bundles are usually generated into the src/ directory. Unless you're
doing something custom, hit enter to keep this default!

Target Directory [src/]: 

What format do you want to use for your generated configuration?

Configuration format (annotation, yml, xml, php) [annotation]: 

  Bundle generation  

> Generating a sample bundle skeleton into app/../src/TestBundle
  created ./app/../src/TestBundle/
  created ./app/../src/TestBundle/TestBundle.php
  created ./app/../src/TestBundle/Controller/
  created ./app/../src/TestBundle/Controller/DefaultController.php
  created ./app/../tests/TestBundle/Controller/
  created ./app/../tests/TestBundle/Controller/DefaultControllerTest.php
  created ./app/../src/TestBundle/Resources/views/Default/
  created ./app/../src/TestBundle/Resources/views/Default/index.html.twig
  created ./app/../src/TestBundle/Resources/config/
  created ./app/../src/TestBundle/Resources/config/services.yml
> Checking that the bundle is autoloaded
FAILED
> Enabling the bundle inside app/AppKernel.php
  updated ./app/AppKernel.php
OK
> Importing the bundle's routes from the app/config/routing.yml file
  updated ./app/config/routing.yml
OK
> Importing the bundle's services.yml from the app/config/config.yml file
  updated ./app/config/config.yml
OK

  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:

 kipik@Anonymous-PC  ~/Documents/Perso/Test 
guijianshi commented 7 years ago

I also encountered this problem, I add new bundle namespace in composer.json "autoload": { "psr-4": { "AppBundle\\": "src/AppBundle", "BlogBundle\\": "src/BlogBundle" }, "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] }, and then, cmd $ composer dump-autoload. the issue is settled

fabpot commented 7 years ago

Closing as there are many duplicated issues of the same.

thomasmoreaumaster commented 7 years ago

Ok but how can we get in touch to know how to fix this issue ?

xabbuh commented 7 years ago

@thomasmoreaumaster see sensiolabs/SensioGeneratorBundle#555

muratji commented 7 years ago

Updated ./composer.json

"psr-4": { "": "src/" },

and then, Run composer dump-autoload.

nicolallias commented 7 years ago

@muratji, you meant in /composer.json

According to https://github.com/symfony/symfony-standard/issues/1098#issuecomment-312863473 the fix is to edit the composer.json at the root of the symfony folder like this:

...
"autoload": {
    "psr-4": { "": "src/" },
    ...
"autoload-dev": {
    "psr-4": { "": "src/" },
...
muratji commented 7 years ago

You're right @nicolallias

It's the /composer.json file at the root of the project

Thank you!

renerpdev commented 7 years ago

i just got an error after doing that, i dont know where to tyoe COMPOSER DUM-AUTOLOAD

nicolallias commented 7 years ago

Hi, since I am not sure about what you are asking, my answer is very fuzzy:

You are supposed to type composer dump-autoload in a console located in your project directory, depending on your operating system (cmd for windows, any shell on unix...), that can be very different. Have a look at the step-by-step documentation. To investigate further about composer.

What is the OriginalProblem? Paste here your error please.

Abazidou commented 6 years ago

In composer.json make this modification. Replace : "psr-4": { "AppBundle\\": "src/AppBundle" }, By : "psr-4": { "": "src/" }, Then execute : composer dump-autoload

jeremiehvt commented 6 years ago

this solution doesn't work at all

ralexandre75 commented 6 years ago

ouf, it's good thanks,

masthisis commented 6 years ago

thanks :

hanenba commented 6 years ago

hello thanks for the solution . it works But now i have this pb

"Fatal error: Class 'CatalogueBundle\CatalogueBundle' not found in C:\wamp64\www\demo\app\AppKernel.php on line 20"

how to solve it??

xabbuh commented 6 years ago

@hanenba Please use one of the support channels if you are looking for help with your code. :)

HassanGouzoul commented 6 years ago

@hanenba ,tu peux nous montrer ton controlleur en nous disant la version sur laquelle tu travailles ?

hanenba commented 6 years ago

sympfony v3.4.11 voici mon pb mp j'ai installé symfony et cree un bundle mais pas de resultat

2018-05-28 5:33 GMT+01:00 Hassan notifications@github.com:

@hanenba https://github.com/hanenba ,tu peux nous montrer ton controlleur en nous disant la version sur laquelle tu travailles ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/symfony/symfony/issues/23630#issuecomment-392416397, or mute the thread https://github.com/notifications/unsubscribe-auth/AlcjiJ-X1WO4b54uA20pnF7RKY4zVQR2ks5t234agaJpZM4OgYYT .

-- Hanen Ben Ayed (+216)24812602 Ingénieur informatique et téchnologie web et Multimédia hanen.mim@gmail.com

hanenba commented 6 years ago

je suis debutaaaaaaante en symfony

2018-06-01 11:42 GMT+01:00 Hanen ben ayed hanen.mim@gmail.com:

sympfony v3.4.11 voici mon pb mp j'ai installé symfony et cree un bundle mais pas de resultat

2018-05-28 5:33 GMT+01:00 Hassan notifications@github.com:

@hanenba https://github.com/hanenba ,tu peux nous montrer ton controlleur en nous disant la version sur laquelle tu travailles ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/symfony/symfony/issues/23630#issuecomment-392416397, or mute the thread https://github.com/notifications/unsubscribe-auth/AlcjiJ-X1WO4b54uA20pnF7RKY4zVQR2ks5t234agaJpZM4OgYYT .

-- Hanen Ben Ayed (+216)24812602 Ingénieur informatique et téchnologie web et Multimédia hanen.mim@gmail.com

-- Hanen Ben Ayed (+216)24812602 Ingénieur informatique et téchnologie web et Multimédia hanen.mim@gmail.com

HassanGouzoul commented 6 years ago

@hanenba être débutante n'est pas un problème il faut juste rester motivée et avoir la volonté d'apprendre. Sinon tu peux stp me confirmer que tu as bien effectué les étape suivantes: 1- installer symfony (avec vérification) 2- Modification du fichier composer.json sur la partie =>"autoload": { "psr-4": { "": "src/" }, 3- executer la commande suivante via l'invite de commande bien-sur en se positionnant sur ton projet: composer dump-autoload 4- Si ton serveur symfony est déja demaré tu fais un logOut (ctrl + c) et un logOn via php bin/console server:run (+ vérification en accedant via ton localhost:numero de port affecté) 5- Création du Bundle via la commande : php bin/console generate:bundle (dans ton cas je suppose que le nom du bundle est CatalogueBundle) 6- Sur ton controlleur du CatalogueBundle il faut mettre la methode et le render (sachant que toute methode sur symfony doit obligatoirement retourner soit un objet response ou template...), tu peux mettre dans ton cas par exemple: `<?php

namespace CatalogueBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller { public function indexAction() { return $this->render('@ Catalogue/Default/index.html.twig'); }

}` le @ et Catalogue sont attaché je les ai détachés juste pour que ça ne sera pas considéré comme une tague par contre dans ton code il faut les attacher

xabbuh commented 6 years ago

@hanenba @HassanGouzoul Please comment in English so that everyone is able to follow your conversation.

HassanGouzoul commented 6 years ago

@xabbuh , with pleasur, I'll repost my comment in english :)

HassanGouzoul commented 6 years ago

@hanenba to be a beginner is not a problem you just have to stay motivated and have the willingness to learn. Otherwise you can confirm that you have done the following steps: 1- install symfony (+verification) 2- Modification of the composer.json on the part => "autoload": { "psr-4": {"": "src /"}, 3- execute the following command via the command prompt of course on your project: composer dump-autoload 4- If your symfony server is already started you make a logOut (ctrl + c) and a logOn via php bin/console server: run (+ verification by accessing via your localhost: port number assigned) 5- Creating the Bundle via the command: php bin/console generate: bundle (in your case I guess the name of the bundle is CatalogueBundle) 6- On the controller of your CatalogueBundle you have to put the method and the render (knowing that any method on symfony must return either an object response or template ...), you can put in your case for example: `<? Php

namespace CatalogueBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller { public function indexAction () { return $this->render ('@ Catalogue/Default/index.html.twig'); }

} ` the @ and Catalogue are attached I detached them just so that it will not be considered as a tag on the other hand in your code it must be attached

hanenba commented 6 years ago

Yes i realized the 5 steps with success . But sorry I didn't understand the 6 steps

Le ven. 1 juin 2018 16:44, Hassan notifications@github.com a écrit :

@hanenba https://github.com/hanenba to be a beginner is not a problem you just have to stay motivated and have the willingness to learn. Otherwise you can confirm that you have done the following steps: 1- install symfony (+verification) 2- Modification of the composer.json on the part => "autoload": { "psr-4": {"": "src /"}, 3- execute the following command via the command prompt of course on your project: composer dump-autoload 4- If your symfony server is already started you make a logOut (ctrl + c) and a logOn via php bin/console server: run (+ verification by accessing via your localhost: port number assigned) 5- Creating the Bundle via the command: php bin/console generate: bundle (in your case I guess the name of the bundle is CatalogueBundle) 6- On the controller of your CatalogueBundle you have to put the method and the render (knowing that any method on symfony must return either an object response or template ...), you can put in your case for example: `<? Php

namespace CatalogueBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller { public function indexAction () { return $this->render ('@ Catalogue/Default/index.html.twig'); }

} ` the @ and Catalogue are attached I detached them just so that it will not be considered as a tag on the other hand in your code it must be attached

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/symfony/symfony/issues/23630#issuecomment-393920851, or mute the thread https://github.com/notifications/unsubscribe-auth/AlcjiLiKv_ZDTPk-N_ndQ7t2CbjPI5Zyks5t4WFYgaJpZM4OgYYT .

HassanGouzoul commented 6 years ago

@hanenba after generating your CatalogueBundle, a folder with the name CatalogBundle will be created on the directory src, you can access to your controller via: src => CatalogueBundle => Controller => DefaultController, and you can put the code that I ' had shown on step 6

Arouna31 commented 5 years ago

Thanks Brother

salmafariji93 commented 5 years ago

1/ Add the "": "src/" in composer.json

"autoload": { "psr-4": { "AppBundle\": "src/AppBundle" , "": "src/" }
.....

2/ Add templating: engine: ['twig'] in app/config/config.yml

framework:

esi: ~

#translator: { fallbacks: ['%locale%'] }
templating:
        engine: ['twig']
secret: '%secret%'
router:
    resource: '%kernel.project_dir%/app/config/routing.yml'
    strict_requirements: ~

......