Symfony there are no commands defined in the "make" namespace
Asked Answered
H

12

29

Following the documentation found here I enter php bin/console make:entity Product in Terminal and get the following error:

[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "make" namespace.

Horatia answered 21/12, 2017 at 1:24 Comment(9)
did you require doctrine and maker ? Installing Doctrine step of the documentation you posted. Also you can see the full list of available commands by typing php bin/consoleAnstus
symfony.com/doc/current/bundles/SymfonyMakerBundle/index.htmlHairy
make:entity is for ORM, not ODM. FWIW we still provide the "old" generator with ODMLitman
@knets I did follow those installation instructions. Doctrine installed fine but running the composer require doctrine maker (as per the documentation) I get the following error [UnexpectedValueException] Could not parse version constraint maker: Invalid version string "maker"Horatia
Only require one package at a time. composer require doctrine followed by composer require makerHairy
@Hairy When I run composer require maker I get the following error: [InvalidArgumentException] Could not find package maker. Did you mean one of these? yab/formmaker yab/crudmaker greabock/maker ctf0/simple-menu symfony/maker-bundle So I ran composer require symfony/maker-bundle and received this: [InvalidArgumentException] Could not find package symfony/maker-bundle at any version matching your PH P version 5.5.36.0Horatia
S4 requres php 7.0 or better. Go back to the docs you were following and select the correct version of symfony in the upper right hand corner. You will ultimately end up using generate:entity not make:entityHairy
@Hairy I'm running Symfony 3.1Horatia
symfony.com/doc/master/bundles/SensioGeneratorBundle/commands/…Hairy
F
49

Maybe you were using the prod environment?

The website-skeleton puts the Maker Bundle in the require-dev section of your composer.json by default:

"require-dev": {
    ...
    "symfony/maker-bundle": "^1.0",
    ...
}

If you've set APP_ENV=prod in your .env file and ran bin/console it would ignore all dev requirements and thus wouldn't enable the Maker Bundle.

Simply enabling the dev environment again (APP_ENV=dev) would do the trick then.

Franzoni answered 17/9, 2018 at 15:36 Comment(1)
I had my env as local switched it back to dev and it did the trickCentra
O
22

make is a command of doctrine component. Just add doctrine maker.

composer require doctrine maker

https://symfony.com/doc/current/doctrine.html#installing-doctrine

Onitaonlooker answered 21/12, 2017 at 4:5 Comment(8)
Nope. You do need doctrine but the make:entity command is actually in the MakerBundle.Hairy
Fixed response with docOnitaonlooker
Running composer require doctrine maker gives me the following error: [UnexpectedValueException] Could not parse version constraint maker: Invalid version string "maker"Horatia
Are you using symfony4?Onitaonlooker
@Onitaonlooker No. 3.1Horatia
The documentation you pointed to in your question is related to Symfony4.Onitaonlooker
You need Symfony ^3.4|^4.0.Lundt
@Onitaonlooker it points to current which now at this time is 4 :)Marston
C
15

You need Symfony 3.4 or higher. For Symfony 3.4 you will need to add it to the registerBundles function in config/AppKernerl():

            if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // [...]
            $bundles[] = new \Symfony\Bundle\MakerBundle\MakerBundle();
        }

Bear in mind that the environment where it is installed is 'dev'.

Coo answered 13/6, 2018 at 10:0 Comment(1)
Exactly what i missed. I forgot that in symfony 3.4 we need to add it to bundles... Thanks.Shiff
P
10

try

composer remove maker
composer require maker --dev

and then

php bin/console make:entity Product

https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html

Pall answered 22/12, 2017 at 11:52 Comment(3)
When I run composer require maker --dev I get the following error: [InvalidArgumentException] Could not find package maker. Did you mean one of these? yab/formmaker yab/crudmaker greabock/maker ctf0/simple-menu symfony/maker-bundle So I ran composer require symfony/maker-bundle and received this: [InvalidArgumentException] Could not find package symfony/maker-bundle at any version matching your PH P version 5.5.36.0Horatia
see here packagist.org/packages/symfony/maker-bundle maker-bundle requires php: ^7.0.8Pall
this hosed all of my bundles. Compile Error: Declaration of Symfony\Component\Cache\Adapter\AbstractAdapter::get(string $key, callable $callback, ?float $beta = NULL) must be compatible with Symfony\Contracts\Cache\CacheInterface::get(string $key, callable $ca llback, ?float $beta = NULL, ?array &$metadata = NULL)Shelving
M
6

You must define the "dev" env in the command line :

php bin/console --env dev
php bin/console make:entity Product --env dev
Maurer answered 3/7, 2019 at 13:14 Comment(0)
N
5

The problem just happend to me. I was in test environment. You have to be in dev environment.

Check APP_ENV value in .env file. It must be the following :

APP_ENV=dev
Nannana answered 29/7, 2020 at 9:22 Comment(1)
Well that is ridiculous - I need to create a migration for a test environment database, which is targeted only when APP_ENV=testThais
V
4

I think you are in prod environment. Check if your the value of APP_ENV inside .env file is not equals to prod.

In case you generate a .env.local file, you have to delete it in your dev environment.

Velma answered 12/8, 2020 at 23:40 Comment(0)
V
1

You can use composer for installer maker bundle, you have install a light version of symfony.

composer require symfony/maker-bundle

but if you have this problem surely need composer doctrine and security

composer require doctrine/orm

with

require doctrine/doctrine-bundle

And

composer require symfony/security-bundle

composer require doctrine/doctrine-migrations-bundle

Now you have this with php bin/console !

make make:auth Creates a Guard authenticator of different flavors

make:command Creates a new console command class

make:controller Creates a new controller class

make:crud Creates CRUD for Doctrine entity class
make:docker:database Adds a database container to your docker-compose.yaml file

make:entity Creates or updates a Doctrine entity class, and optionally an API Platform resource

make:fixtures Creates a new class to load Doctrine fixtures

make:form Creates a new form class

make:message Creates a new message and handler

make:messenger-middleware Creates a new messenger middleware

make:migration Creates a new migration based on database changes

make:registration-form Creates a new registration form system

make:reset-password Create controller, entity, and repositories for use with symfonycasts/reset-password-bundle
make:serializer:encoder Creates a new serializer encoder class

make:serializer:normalizer Creates a new serializer normalizer class

make:stimulus-controller Creates a new Stimulus controller

make:subscriber Creates a new event subscriber class

make:test [make:unit-test|make:functional-test] Creates a new test class

make:twig-extension Creates a new Twig extension class

make:user Creates a new security user class

make:validator Creates a new validator and constraint class

make:voter Creates a new security voter class

Velvetvelveteen answered 5/7, 2022 at 9:34 Comment(0)
L
0

If you have installed symfony / maker-bundle for the dev mode you will only be able to use it for this mode. If you are in prod mode then go to dev mode and try again

Lowminded answered 6/2, 2019 at 16:18 Comment(0)
R
0

Try composer require symfony/maker-bundle --dev it work for me.

Rolan answered 27/5, 2019 at 13:48 Comment(0)
M
0
composer require symfony/maker-bundle --dev
Milks answered 19/11, 2020 at 15:15 Comment(0)
J
-1

To fix the problem you just create new project with (full properties), here is command for create a project:

symfony new --full project-name

after you create project like the command above, you now can able to use (make).

Juglandaceous answered 29/5, 2022 at 2:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.