New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate bundle autoload failed since symfony 3.3.5 in windows #23630

Closed
adityarai opened this Issue Jul 23, 2017 · 27 comments

Comments

Projects
None yet
@adityarai
Copy link

adityarai commented Jul 23, 2017

Checking that the bundle is autoloaded FAILED

@dorcyv

This comment has been minimized.

Copy link

dorcyv commented Jul 23, 2017

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

This comment has been minimized.

Copy link

guijianshi commented Jul 24, 2017

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

This comment has been minimized.

Copy link
Member

fabpot commented Jul 27, 2017

Closing as there are many duplicated issues of the same.

@fabpot fabpot closed this Jul 27, 2017

@thomasmoreaumaster

This comment has been minimized.

Copy link

thomasmoreaumaster commented Jul 31, 2017

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

@xabbuh

This comment has been minimized.

Copy link
Member

xabbuh commented Aug 1, 2017

@muratji

This comment has been minimized.

Copy link

muratji commented Sep 6, 2017

Updated ./composer.json

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

and then,
Run composer dump-autoload.

@nicolallias

This comment has been minimized.

Copy link

nicolallias commented Sep 12, 2017

@muratji, you meant in /composer.json

According to symfony/symfony-standard#1098 (comment)
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

This comment has been minimized.

Copy link

muratji commented Sep 12, 2017

You're right @nicolallias

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

Thank you!

@2rhop

This comment has been minimized.

Copy link

2rhop commented Sep 28, 2017

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

@nicolallias

This comment has been minimized.

Copy link

nicolallias commented Oct 5, 2017

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

This comment has been minimized.

Copy link

Abazidou commented Dec 6, 2017

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

@jeremiehvt

This comment has been minimized.

Copy link

jeremiehvt commented Feb 7, 2018

this solution doesn't work at all

@ralexandre75

This comment has been minimized.

Copy link

ralexandre75 commented Feb 26, 2018

ouf, it's good thanks,

@mas1375

This comment has been minimized.

Copy link

mas1375 commented Mar 3, 2018

thanks :

@hanenba

This comment has been minimized.

Copy link

hanenba commented May 14, 2018

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

This comment has been minimized.

Copy link
Member

xabbuh commented May 14, 2018

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

@HassanGouzoul

This comment has been minimized.

Copy link

HassanGouzoul commented May 28, 2018

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

@hanenba

This comment has been minimized.

Copy link

hanenba commented Jun 1, 2018

@hanenba

This comment has been minimized.

Copy link

hanenba commented Jun 1, 2018

@HassanGouzoul

This comment has been minimized.

Copy link

HassanGouzoul commented Jun 1, 2018

@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

This comment has been minimized.

Copy link
Member

xabbuh commented Jun 1, 2018

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

@HassanGouzoul

This comment has been minimized.

Copy link

HassanGouzoul commented Jun 1, 2018

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

@HassanGouzoul

This comment has been minimized.

Copy link

HassanGouzoul commented Jun 1, 2018

@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

This comment has been minimized.

Copy link

hanenba commented Jun 1, 2018

@HassanGouzoul

This comment has been minimized.

Copy link

HassanGouzoul commented Jun 1, 2018

@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

This comment has been minimized.

Copy link

Arouna31 commented Oct 25, 2018

Thanks Brother

@salmafariji93

This comment has been minimized.

Copy link

salmafariji93 commented Nov 1, 2018

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: ~
......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment