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.

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/console
    – knetsi
    Commented Dec 21, 2017 at 1:42
  • make:entity is for ORM, not ODM. FWIW we still provide the "old" generator with ODM
    – malarzm
    Commented Dec 21, 2017 at 14:00
  • @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" Commented Dec 22, 2017 at 11:02
  • Only require one package at a time. composer require doctrine followed by composer require maker
    – Cerad
    Commented Dec 22, 2017 at 13:02

12 Answers 12

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.

1
  • 2
    I had my env as local switched it back to dev and it did the trick
    – Tofandel
    Commented Jan 19, 2022 at 14:43
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

8
  • 1
    Nope. You do need doctrine but the make:entity command is actually in the MakerBundle.
    – Cerad
    Commented Dec 21, 2017 at 14:06
  • Fixed response with doc
    – sensorario
    Commented Dec 22, 2017 at 7:02
  • 4
    Running composer require doctrine maker gives me the following error: [UnexpectedValueException] Could not parse version constraint maker: Invalid version string "maker" Commented Dec 22, 2017 at 11:03
  • Are you using symfony4?
    – sensorario
    Commented Dec 22, 2017 at 14:38
  • 1
    You need Symfony ^3.4|^4.0. Commented Jan 24, 2018 at 14:09
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'.

1
  • 2
    Exactly what i missed. I forgot that in symfony 3.4 we need to add it to bundles... Thanks. Commented Nov 14, 2018 at 15:05
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

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.0 Commented Dec 22, 2017 at 18:29
  • see here packagist.org/packages/symfony/maker-bundle maker-bundle requires php: ^7.0.8 Commented Dec 24, 2017 at 5:31
  • 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)
    – nomistic
    Commented Sep 24, 2019 at 18:47
6

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

php bin/console --env dev
php bin/console make:entity Product --env dev
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
1
  • Well that is ridiculous - I need to create a migration for a test environment database, which is targeted only when APP_ENV=test
    – Starwave
    Commented Dec 2, 2022 at 14:15
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.

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

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

0

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

0
0
composer require symfony/maker-bundle --dev
-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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.