Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Symfony logo

Solution – Why some console commands are not working in Symfony

This post is going to be a short and quick. Recently I have been working a lot with symfony and every time i face some issue turns out there is very simple solution but sometimes it doesn’t strikes as obvious solution, until we find a solution on slackoverflow or github. In this post I am going to give one such solution.

What exactly is the problem ?

I lot a project because of disk crash and cloned back from git. and downloaded my .env file from production server. I did composer install which gave me all that I need, simple right ? Well I was happy and started making changes and here i came to creating entity. We all know simplest way is to use php bin/console make:entity. That’s what I did but, boom, console is red with an error.

$ php bin/console make:entity

There are no commands defined in the “make” namespace.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
You may be looking for a command provided by the "MakerBundle" which is currently not installed. Try running "composer require symfony/maker-bundle --dev".
You may be looking for a command provided by the "MakerBundle" which is currently not installed. Try running "composer require symfony/maker-bundle --dev".
You may be looking for a command provided by the "MakerBundle" which is currently not installed. Try running "composer require symfony/maker-bundle --dev".

So what did i do wrong ? I tried composer install, composer update but no use. I checked my composer.json and it was there. I checked vendor directory and it was there as well. So why it doesn’t work ?

Simple solution, which was obvious but I missed like lot of other people, as I found out when googling.

Solution:

Some command namespaces are simply not available when you are running in production mode. Solution is to use your local .env file so the environment variable APP_ENV is set to dev like APP_ENV=dev. Then clear your cache php bin/console cache:clear --env=dev and it’ll all be fine and namespaces which are limited to dev will be available for use.

Leave a Comment

Your email address will not be published. Required fields are marked *

Buy Me A Coffee
If you find my content helpful, please consider supporting me!