Getting started with Symfony5 and instructions on Windoows
Follow the getting started guide.
Then look through the commits. Each commit details
- A description of what the commit does
- The Command which does it
Requirements
-
Command line (I'm using Git Bash from Git for Windows)
-
PHP 7.4 - See XAMPP below -
php
should be accesible from the command line -
Local MySQL Database - See XAMPP below
-
(Optional) PHP CS Fixer
I use XAMPP, downloading version 7.4.x.
Add C:\xampp\php
to the PATH
- Start, search 'edit the system environment variables'
- "Environment Variables"
- User Variables > click
Path
> click 'edit' - Add
C:\xampp\php
To get the project started...
run (what this project uses)
symfony new --full symfony5-demo
This creates a new symfony project in a subfolder called symfony5-demo
Alternatively, this can be used for an API centric (no templating etc) project
symfony new symfony5-demo
copy .env
to .env.local
. To update any project settings, edit .env.local
. .env.local
is excluded in Git.
Use .env for default values.
Do not store and commit secrets in .env
other than default, generic values.
In .env.local
, uncomment the line and set the username, password and db name accordingly.
DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"
Note: update serverVersion to your corresponding version. XAMPP reported 10.4.14-MariaDB to me
There is a secrets system which allows you to store secrets in the Git repository (protected by a uncommited private key). I don't go into it here but I use it in other projects.
Now visit /commits/main to see the list of commits. The commit message contains the command or action taken and the resulting diff
You can configure Apache in XAMPP but I find it easier to use the Symfony CLI built-in
cd [root of project]
symfony serve
You can access the site on https://localhost:8000
Upon first run, follow the instructions to install to install the dev certificate (if you want or you'll get browser warnings)
This is usualy because of relation. You must referece a child relation in string format
key: "/api/Object/[id]"
e.g.
key: "/api/Person/1"