Commonly used OroCRM console commands

When we started working with OroCRM we have met problems with differences between Symfony core commands and OroCRM commands. That is why we decided to share this experience and prepared a list with the most common commands for everyday work with OroCRM such as cache clearing, migration, entities.

First of all, let’s review the command for clearing the cache. If you are working with OroCRM – you have to clear the cache quite often. OroCRM has two execution modes: “dev” (developer mode used for debugging) and “prod” (production mode used for production environment). You can always switch the mode by running:

php app/console cache:clear -e dev
php app/console cache:clear -e prod

Note that the first command is used for switching to the “dev” mode and the second one is for switching to production mode.

Sometimes, you will have to clear cache manually by removing the directories. Use the following command to do it:

rm -rf app/cache/*

And if you’ve received the error like “failed to remove `some_directory’: Directory not empty” – solve it with:

rmdir --ignore-fail-on-non-empty app/cache/path_to_directory

and after it run “rm -rf app/cache/*”.

After clearing the cache manually you must run php app/console cache:clear -e dev or php app/console cache:clear -e prod to warm up the cache.

Work with Migrations

Before executing migrations, make sure that the process will not produce an error or break your database. So, to test the migrations script you can run it with the “dry-run” mode. For this porpose use the following command with the –dry-run parameter.

php app/console oro:migration:load --dry-run

Also, you can list the SQL commands of your migrations:

php app/console oro:migration:load --dry-run --show-queries

If you do not receive any errors and the command is not failed, you can execute you migrations – just run the command with –force parameter. Moreover, we recommended to use –timeout=0 parameter:

php app/console oro:migration:load --force --timeout=0

Note that the previously mentioned commands execute the migrations for all bundles of your application. But you can run the migrations for a single bundle:

php app/console oro:migration:load --force --bundles="AtwixTestBundle"

Also, you can exclude a bundle by:

php app/console oro:migration:load --force --exclude="AtwixTestBundle"

Furthermore, for data migrations execution you can use the following command:

php app/console oro:migration:data:load

And already with this command you can also use parameters mentioned above:

php app/console oro:migration:data:load  --bundles="AtwixTestBundle"
php app/console oro:migration:data:load --exclude="AtwixTestBundle"

Work with Entities

If you change some configuration parameters of an entity or add a new entity with the configuration parameters you should use the following commands to update the global entities’ configuration:

php app/console oro:entity-config:update --dry-run
php app/console oro:entity-config:update --force

It is a good practice to do it by:

php app/console oro:entity-config:cache:clear

before running the entity config update.

You can debug an entity config using the following command:

php app/console oro:entity-config:debug "Atwix\Bundle\TestBundle\Entity\TestEntity"

In addition, you can debug a single scope of config. Fro this you just need to add a parameter with the name of the scope:

php app/console oro:entity-config:debug "Atwix\Bundle\TestBundle\Entity\TestEntity" --scope ownership

Pay attention that if you work with the extend entity, you can use these commands to update the extended entities config:

php app/console oro:entity-extend:cache:clear
php app/console oro:entity-extend:update-config
php app/console oro:entity-extend:update-schema

Sometimes, our entities and database tables might be unsynchronized, you can check it by running:

php app/console doctrine:schema:update --dump-sql

and fix it with:

php app/console doctrine:schema:update --force

And one more command will help you get a list of all your bundles. It is useful, for example, when you are not sure that your bundle is registered in the system.

php app/console container:debug --parameter=kernel.bundles

This article does not contain a full list of commands, but if you want to find more commands just run:

php app/console list

As a result, you will receive all of them in the list – it includes the custom commands that you or other developers have added to OroCRM application.

We hope you will find this information useful and the mentioned commands will help in your work with OroCRM.

Clients

Smart Brands Choose Us.

From Mark Cuban and Sir Richard Branson backed startups, to Inc 500 US Fastest Growing Companies and Global Brands choose us to deliver and support unparalleled eСommerce experience for their customers.