systemsdk / docker-symfony-api
JSON REST API
Fund package maintenance!
www.paypal.com/donate/?hosted_button_id=4ZZHRZHENRPZN
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 7
Forks: 8
Open Issues: 2
Type:project
Requires
- php: ^8.2.0
- ext-amqp: *
- ext-ctype: *
- ext-iconv: *
- ext-json: *
- ext-mbstring: *
- ext-pdo: *
- ext-pdo_mysql: *
- beberlei/doctrineextensions: ^1.3
- doctrine/annotations: ^1.14
- doctrine/doctrine-bundle: ^2.8
- doctrine/doctrine-migrations-bundle: ^3.2
- doctrine/orm: ^2.14
- dukecity/command-scheduler-bundle: ^5.0
- elasticsearch/elasticsearch: ^7.17
- gedmo/doctrine-extensions: ^3.10
- lexik/jwt-authentication-bundle: ^2.16
- mark-gerarts/automapper-plus-bundle: ^1.4
- matomo/device-detector: ^6.0
- matthiasnoback/symfony-console-form: ^5.3
- nelmio/api-doc-bundle: ^4.10
- nelmio/cors-bundle: ^2.2
- phpdocumentor/reflection-docblock: ^5.3
- ramsey/uuid-doctrine: ^2.0
- symfony/amqp-messenger: 6.2.*
- symfony/asset: 6.2.*
- symfony/config: 6.2.*
- symfony/console: 6.2.*
- symfony/doctrine-messenger: 6.2.*
- symfony/dotenv: 6.2.*
- symfony/expression-language: 6.2.*
- symfony/flex: ^2.2
- symfony/form: 6.2.*
- symfony/framework-bundle: 6.2.*
- symfony/http-client: 6.2.*
- symfony/intl: 6.2.*
- symfony/mailer: 6.2.*
- symfony/messenger: 6.2.*
- symfony/mime: 6.2.*
- symfony/monolog-bundle: ^3.8
- symfony/notifier: 6.2.*
- symfony/process: 6.2.*
- symfony/property-access: 6.2.*
- symfony/property-info: 6.2.*
- symfony/proxy-manager-bridge: 6.2.*
- symfony/routing: 6.2.*
- symfony/runtime: 6.2.*
- symfony/security-bundle: 6.2.*
- symfony/serializer: 6.2.*
- symfony/string: 6.2.*
- symfony/translation: 6.2.*
- symfony/twig-bundle: 6.2.*
- symfony/validator: 6.2.*
- symfony/web-link: 6.2.*
- symfony/yaml: 6.2.*
- twig/extra-bundle: ^2.12|^3.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- doctrine/doctrine-fixtures-bundle: ^3.4
- roave/security-advisories: dev-latest
- symfony/browser-kit: 6.2.*
- symfony/debug-bundle: 6.2.*
- symfony/maker-bundle: ^1.48
- symfony/requirements-checker: ^2.0
- symfony/stopwatch: 6.2.*
- symfony/var-dumper: 6.2.*
- symfony/web-profiler-bundle: 6.2.*
- systemsdk/easy-log-bundle: 2.0.*
Conflicts
- symfony/debug: <3.3
- symfony/symfony: *
- symfony/twig-bundle: <3.3
This package is auto-updated.
Last update: 2023-02-01 19:23:25 UTC
README
Docker environment (based on official php and mysql docker hub repositories) required to run Symfony with JSON REST API example.
Requirements
- Docker version 18.06 or later
- Docker compose version 1.22 or later
- An editor or IDE
- MySQL Workbench
Note: OS recommendation - Linux Ubuntu based.
Components
- Nginx 1.23
- PHP 8.2 fpm
- MySQL 8
- Symfony 6
- RabbitMQ 3
- Elasticsearch 7
- Kibana 7
- Redis 7
Setting up Docker and docker-compose
1.For installing Docker please follow steps mentioned on page install on Ubuntu linux or install on Mac/Windows.
2.For installing docker-compose as Linux Standalone binary
please follow steps on the page install compose if you are using Linux OS.
Note: Please run next cmd after above step 2 if you are using Linux OS: sudo usermod -aG docker $USER
Setting up DEV environment
1.You can clone this repository from GitHub or install via composer.
If you have installed composer and want to install environment via composer you can use next cmd command:
composer create-project systemsdk/docker-symfony-api api-example-app
2.Set another APP_SECRET for application in .env.prod and .env.staging files.
Note 1: You can get unique secret key for example here.
Note 2: Do not use .env.local.php on dev and test environment (delete it if exist).
Note 3: If you want to change default web port/xdebug configuration you can create .env.local file and set some params (see .env file).
Note 4: Delete var/mysql-data folder if it exists.
3.Add domain to local 'hosts' file:
127.0.0.1 localhost
4.Configure /docker/dev/xdebug-main.ini
(Linux/Windows) or /docker/dev/xdebug-osx.ini
(MacOS) (optional):
- In case you need debug only requests with IDE KEY: PHPSTORM from frontend in your browser:
xdebug.start_with_request = no
Install locally in Firefox extension "Xdebug helper" and set in settings IDE KEY: PHPSTORM
- In case you need debug any request to an api (by default):
xdebug.start_with_request = yes
5.Elasticsearch is pre-configured with the following privileged bootstrap user(you can use it in order to enter in Kibana):
user: elastic password: changeme
Note: For prod/staging environment another password should be used.
6.Build, start and install the docker images from your terminal:
make build make start make composer-install make generate-jwt-keys
7.Make sure that you have installed migrations / created roles and groups / messenger transports / elastic template:
make migrate make create-roles-groups make migrate-cron-jobs make messenger-setup-transports make elastic-create-or-update-template
8.In order to use this application, please open in your browser next urls:
Setting up STAGING environment locally
1.You can clone this repository from GitHub or install via composer.
Note: Delete var/mysql-data folder if it is exist.
If you have installed composer and want to install environment via composer you can use next cmd command:
composer create-project systemsdk/docker-symfony-api api-example-app
2.Elasticsearch is pre-configured with the following privileged bootstrap user:
user: elastic
password: ********
3.Build, start and install the docker images from your terminal:
make build-staging make start-staging make generate-jwt-keys
4.Make sure that you have installed migrations / created roles and groups / messenger transports / elastic template:
make migrate-no-test make create-roles-groups make migrate-cron-jobs make messenger-setup-transports make elastic-create-or-update-template
Setting up PROD environment locally
1.You can clone this repository from GitHub or install via composer.
If you have installed composer and want to install environment via composer you can use next cmd command:
composer create-project systemsdk/docker-symfony-api api-example-app
2.Edit docker-compose-prod.yml and set necessary user/password for MySQL and RabbitMQ.
Note: Delete var/mysql-data folder if it is exist.
3.Edit env.prod and set necessary user/password for MySQL and RabbitMQ.
4.Elasticsearch is pre-configured with the following privileged bootstrap user:
user: elastic
password: ********
5.Build, start and install the docker images from your terminal:
make build-prod make start-prod make generate-jwt-keys
6.Make sure that you have installed migrations / created roles and groups / messenger transports / elastic template:
make migrate-no-test make create-roles-groups make migrate-cron-jobs make messenger-setup-transports make elastic-create-or-update-template
How to enable paid features for Elasticsearch
Switch the value of Elasticsearch's xpack.license.self_generated.type
option from basic
to trial
(/docker/elasticsearch/config/elasticsearch.yml
).
Getting shell to container
After application will start (make start
) and in order to get shell access inside symfony container you can run following command:
make ssh
Note 1: Please use next make commands in order to enter in other containers: make ssh-nginx
, make ssh-supervisord
, make ssh-mysql
, make ssh-rabbitmq
.
Note 2: Please use exit
command in order to return from container's shell to local shell.
Building containers
In case you edited Dockerfile or other environment configuration you'll need to build containers again using next commands:
make stop make build make start
Note 1: Please use next command if you need to build staging environment make build-staging
instead make build
.
Note 2: Please use next command if you need to build prod environment make build-prod
instead make build
.
Start and stop environment
Please use next make commands in order to start and stop environment:
make start make stop
Note 1: For staging environment need to be used next make commands: make start-staging
, make stop-staging
.
Note 2: For prod environment need to be used next make commands: make start-prod
, make stop-prod
.
Additional main command available
make build make build-test make build-staging make build-prod make start make start-test make start-staging make start-prod make stop make stop-test make stop-staging make stop-prod make restart make restart-test make restart-staging make restart-prod make env-staging make env-prod make generate-jwt-keys make ssh make ssh-root make ssh-nginx make ssh-supervisord make ssh-mysql make ssh-rabbitmq make ssh-elasticsearch make ssh-kibana make composer-install-no-dev make composer-install make composer-update make info make logs make logs-nginx make logs-supervisord make logs-mysql make logs-rabbitmq make logs-elasticsearch make logs-kibana make drop-migrate make migrate make migrate-no-test make migrate-cron-jobs make fixtures make create-roles-groups make messenger-setup-transports make elastic-create-or-update-template make phpunit make report-code-coverage make phpcs make ecs make ecs-fix make phpmetrics make phpcpd make phpmd make phpstan make phpinsights etc....
Notes: Please see more commands in Makefile
Architecture & packages
- Symfony 6
- doctrine-migrations-bundle
- doctrine-fixtures-bundle
- command-scheduler-bundle
- phpunit
- phpunit-bridge
- browser-kit
- css-selector
- security-checker
- messenger
- composer-bin-plugin
- composer-normalize
- composer-unused
- composer-require-checker
- requirements-checker
- security-advisories
- jwt-authentication-bundle
- automapper-plus-bundle
- symfony-console-form
- api-doc-bundle
- cors-bundle
- device-detector
- uuid-doctrine
- doctrine-extensions
- easy-log-bundle
- php-coveralls
- easy-coding-standard
- PhpMetrics
- phpcpd
- phpmd
- phpstan
- phpinsights
- beberlei/doctrineextensions
- elasticsearch
- rector
External links / resources
- Symfony Flex REST API: code in "src/" folder forked from Symfony Flex REST API.
Guidelines
- Commands
- Development
- Testing
- IDE PhpStorm configuration
- Xdebug configuration
- Swagger
- Postman
- Redis GUI
- Messenger component
Working on your project
- For new feature development, fork
develop
branch into a new branch with one of the two patterns:feature/{ticketNo}
- Commit often, and write descriptive commit messages, so its easier to follow steps taken when reviewing.
- Push this branch to the repo and create pull request into
develop
to get feedback, with the formatfeature/{ticketNo}
- "Short descriptive title of Jira task". - Iterate as needed.
- Make sure that "All checks have passed" on CircleCI(or another one in case you are not using CircleCI) and status is green.
- When PR is approved, it will be squashed & merged, into
develop
and later merged intorelease/{No}
for deployment.
Note: You can find git flow detail example here.