Important
You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Set up Environment for OroPlatform Based Application with Docker and Symfony Server¶
Hint
This feature is available since OroCommerce v4.1.7. To check which application version you are running,
see the system information or run composer info oro/platform
.
During development, you can use Docker to run various application services (MySQL, Postgres, ElasticSearch, RabbitMQ, Redis and MailCatcher), but for simplicity, performance and reliability have PHP and NodeJS installed locally on a host machine.
Set Up the Environment¶
Hint
There are quick guides to setup Docker and Symfony Server development stack:
Development Stack
PHP, Composer, Node.js, and NPM should be installed locally for a better development experience.
Symfony Local Web Server is used to make you more productive while developing applications. This server is not intended for production use. It supports HTTP/2, TLS/SSL, automatic generation of security certificates, local domains, and many other features.
Docker is used to run application services.
Docker Compose is used to manage them all with a single command.
Note
PHP and NodeJS should meet the System Requirements.
Recommendations
To avoid reaching composer API rate limit and to work with enterprise applications, configure GitHub OAuth token:
composer config -g github-oauth.github.com <oauthtoken>
Install the Application¶
Get the Oro application source code and go to the application folder.
Run application services
docker-compose up -d
Note
On Linux, it may not work if you use Docker as a root user. In this case, consider adding your user to the “docker” group with:
sudo usermod -aG docker your-user
Install application dependencies
composer install -n
If you are using an Enterprise edition application, update the parameters.yml file.
composer set-parameters database_driver=pdo_pgsql search_engine_name=elastic_search message_queue_transport=amqp message_queue_transport_config="{host: '%env(ORO_MQ_HOST)%', port: '%env(ORO_MQ_PORT)%', user: '%env(ORO_MQ_USER)%', password: '%env(ORO_MQ_PASSWORD)%', vhost: '/'}" redis_dsn_cache='%env(ORO_REDIS_URL)%/1' redis_dsn_doctrine='%env(ORO_REDIS_URL)%/2'
Install Oro application
symfony console oro:install -vvv --sample-data=y --application-url=https://127.0.0.1:8000 --user-name=admin --user-email=admin@example.com --user-firstname=John --user-lastname=Doe --user-password=admin --organization-name=Oro --timeout=0 --symlink --env=prod -n
Use a Symfony Server¶
To automatically apply environment variables exposed by Symfony Server
from Docker Compose and to use the proper PHP version, you should run
all the symfony application commands using symfony console
instead
of bin/console
. Use symfony php
to run php binaries
using proper PHP version and expose environment variables from the application services defined with Docker Compose.
Note
On Windows with WSL2 the website is accessible using https://localhost:8000, instead of https://127.0.0.1:8000.
Run Symfony Server in a Dev
Environment¶
symfony server:start -d
Run Symfony Server in a Prod
Environment¶
symfony server:start -d --passthru=index.php
Open the Application in a Browser¶
symfony open:local
Check Application Logs¶
symfony server:log
Switch PHP version¶
You can have multiple versions of PHP versions locally. To use a specific PHP version for the project, go to the project root folder and run:
echo 7.3 > .php-version
This will switch the php version to 7.3 for Symfony Server and all the
console commands wrapped with symfony
.
Run Message Consumer in the Background¶
symfony run -d php bin/console oro:message-queue:consume -vv
You can also ask symfony to restart the message consumer when changes happen in src/
folder:
symfony run -d --watch=src php bin/console oro:message-queue:consume -vv
Check Symfony Server status¶
symfony server:status
For more details, see: Symfony Local Web Server.
Enable Local Domain Names¶
By default, projects are accessible at a random port of the 127.0.0.1 local IP.
You can enable local domains by setting up the Local Proxy.
Manage Application Services¶
All application services are defined in the docker-compose.yml
file.
By default, the docker-compose.yml
file shipped with an application has a
set of recommended services for each application:
For community edition applications: MySQL and MailCatcher.
For enterprise edition applications: Postgres, ElasticSearch, RabbitMQ, Redis and MailCatcher.
Override Docker Compose Configuration Locally¶
You can use docker-compose.override.yml
file to override Docker
Compose configuration locally. By default, the file is in .gitignore
.
Note
For an enterprise application, you first have to update the parameters.yml file to start working with the application services.
Run Application Services¶
docker-compose up -d
Check Services Logs¶
docker-compose logs -f
Check Application Services Status¶
docker-compose ps
Stop Application Services (No Data Loss)¶
docker-compose stop
Destroy Application Services with all Volumes (Data Loss)¶
docker-compose down -v
For more details, see Overview of Docker Compose.
Store Sessions in Redis¶
It is not recommended to store sessions on the same redis server as the cache, but for testing purpose, you can enable it with the following command:
composer set-parameters session_handler="snc_redis.session.handler" redis_dsn_session="%env(ORO_REDIS_URL)%/0"
Troubleshooting¶
Environment variable not found: “ORO_REDIS_URL”
This error appears when the Symfony server does not pass environment variables from the Docker Compose to the application.
Make sure that all the application services are up and healthy with docker-compose ps
. There should be a redis
service in the list.
If the list is empty, run docker-compose up -d
to start all the services.
An exception occured while establishing a connection to figure out your platform version
Make sure all the application services are up and healthy with docker-compose ps
. There should be pgsql
or mysql
service in the list.
If the list is empty, run docker-compose up -d
to start all the services.