28

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.

MaxiGui
  • 6,190
  • 4
  • 16
  • 33
lola_the_coding_girl
  • 843
  • 2
  • 10
  • 22
  • 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 Dec 21 '17 at 01:42
  • https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html – Cerad Dec 21 '17 at 01:48
  • `make:entity` is for ORM, not ODM. FWIW we still provide the "old" generator with ODM – malarzm Dec 21 '17 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"` – lola_the_coding_girl Dec 22 '17 at 11:02
  • Only require one package at a time. composer require doctrine followed by composer require maker – Cerad Dec 22 '17 at 13:02
  • @Cerad 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.0` – lola_the_coding_girl Dec 22 '17 at 18:30
  • 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:entity – Cerad Dec 22 '17 at 18:33
  • @Cerad I'm running Symfony 3.1 – lola_the_coding_girl Dec 22 '17 at 19:20
  • https://symfony.com/doc/master/bundles/SensioGeneratorBundle/commands/generate_doctrine_entity.html – Cerad Dec 22 '17 at 19:22

12 Answers12

45

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.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
flu
  • 14,307
  • 8
  • 74
  • 71
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

sensorario
  • 20,262
  • 30
  • 97
  • 159
14

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'.

Marcos Labad
  • 1,123
  • 10
  • 11
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

sensorario
  • 20,262
  • 30
  • 97
  • 159
Oleg Kyryliv
  • 111
  • 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` – lola_the_coding_girl Dec 22 '17 at 18:29
  • see here https://packagist.org/packages/symfony/maker-bundle maker-bundle requires php: ^7.0.8 – Oleg Kyryliv Dec 24 '17 at 05: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 Sep 24 '19 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
Akiro
  • 111
  • 1
  • 3
4

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
vincent PHILIPPE
  • 975
  • 11
  • 26
  • Well that is ridiculous - I need to create a migration for a test environment database, which is targeted only when `APP_ENV=test` – Starwave Dec 02 '22 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

O.Ndiaye
  • 1
  • 1
0

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

atef zoiaidi
  • 1
  • 1
  • 1
0
composer require symfony/maker-bundle --dev
Mert Metin
  • 411
  • 1
  • 8
  • 21
0

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).