nginx 17.2 - php7.3-fpm - postgresql 11.2 - redis
In order to run this run-time system locally you will need a few tools installed:
Clone the sf4d Git Repo from https://github.com/papahelmsman/sf4d to a new folder.
First, clone this repository :
git clone https://github.com/papahelmsman/sf4d.git [path-tu-your-project-folder]
cd [path-tu-your-project-folder]
docker-compose up -d
Don't forget to add sf4d.localhost
in your hosts
file.
To run Docker, your machine must have a 64-bit operating system running Windows 7 or higher.
I use Docker Toolbox on Windows 7 (64-bit) and my host record is as follows:
192.168.99.100 sf4d.dockerhost
Check if your development environment is ready to go :
sf4d.dockerhost
Your browser should redirect your request to secure connection:
https://sf4d.dockerhost
And you should see your test index
page.
Congrats! It works!
Now we can start development.
Next, put your Symfony application into app
folder.
Stop your containers:
docker-compose down
Clean th /app
folder. Remove public
folder from /app
.
Create Symfonyy application's template:
composer create-project symfony/website-skeleton ./app
or if you prefer to use symfony
binary:
symfony new --full ./app
Edit your doctrine cinfiguration file //app/config/packages/doctrine.yaml
.
Add in the beginning:
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
And change dbal
section:
dbal:
# configure these for your database server
driver: 'pdo_pgsql'
server_version: '11.2'
charset: utf8
default_table_options:
charset: utf8
collate: ~
url: '%env(resolve:DATABASE_URL)%'
schema_filter: '~^(?!work_projects_tasks_seq)~'
Change the DATABASE
parameters in /app/.env
.
Comment out the following line:
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
and add below:
DATABASE_URL="pgsql://db_user:db_password@127.0.0.1:5432/db_name"
Substitute your credentials:
DATABASE_URL=pgsql://symfonist:secret@192.168.99.100:54321/app_db
Then, run docker containers:
docker-compose up -d --build
http://sf4d.dockerhost:2000/
System: PostgreSQL Server: app-db Username: symfonist Password: secret Database: app_db
You can change these credentials in the .env
file and then rebuild containers using coamand:
docker-compose up -d --build