Skip to content

Commit

Permalink
Merge pull request #588 from leepeuker/add-developer-phpstorm-docs
Browse files Browse the repository at this point in the history
Add phpstorm code style scheme and documentation how to use it
  • Loading branch information
leepeuker authored Feb 24, 2024
2 parents 41e67a1 + 9428ab5 commit d60534e
Show file tree
Hide file tree
Showing 2 changed files with 318 additions and 12 deletions.
57 changes: 45 additions & 12 deletions docs/development/setup.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
### Local development setup

To set up a basic local development environment follow these steps:

- run `cp .env.development.example .env` and edit the `.env` file to customize the local environment
- run `make build` to build the docker containers using compose and run all necessary steps for an initial setup like
- create the database
- install composer dependencies
- run database migrations
- create the storage symlink
- clone the repository
- copy the file `.env.development.example` to `.env` and customize it for your local environment
- make sure the `USER_ID` matches your UID (`echo $UID`)
- adjust `DOCKER_COMPOSE_BIN` if you have the legacy docker-compose binary
- add your `TMDB_API_KEY`
- run `make build` to build the docker containers and to run all necessary steps for an initial setup like
- create the database
- install composer dependencies
- run database migrations
- create the storage symlink

The application should be up-to-date and running locally now.
The application should be up-to-date and running locally now.

Use the following cli commands to manage your local environment:

- run `make down` to stop all containers
- run `make up` to start all containers again (`build` is only for the initial setup!)
- run `make reup` to stop and restart all containers
- run `make down` to stop all containers
- run `make reup` to stop and restart all containers
- run `make app_database_migrate` execute the database migrations
- run `make app_jobs_process` process the next job from the queue (see database table `job_queue`)

### Api docs
### IDE recommendation: PhpStorm

We recommend to use PhpStorm and to import the Movary code style scheme (found at `settings/phpstorm.xml`).
For import instructions see the [official docs](https://www.jetbrains.com/help/phpstorm/configuring-code-style.html#import-export-schemes).

To apply the code style rules use at least the following features:

- `Reformat code` (more info [here](https://www.jetbrains.com/help/phpstorm/rearrange-code.html))
- `Rearrange code` (more info [here](https://www.jetbrains.com/help/phpstorm/rearrange-code.html))
- `Optimize imports`

Notes:

- Please apply the code style rules for every file you changed
- To find the default shortcuts for the features and/or customize search for them in Settings -> Keymap
- If you use the PhpStorm UI for git you can execute the features automatically before every commit (Settings -> Version Control -> Commit -> Commit Checks)

### Documentation

#### General

We use [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for the documentation.

This is part of the default development docker compose setup and can be reached via `http://127.0.0.1:8000`.

To adjust the documentation files look into the `docs` directory and the configuration of MkDocs is in `mkdocs.yml`.

#### Api

Checkout the API docs via the url path `{your-movie-url}/docs/api`.
Checkout the API docs via the url `http://127.0.0.1/docs/api`.

This uses the schema defined in the file `/docs/openapi.json`
This uses the schema defined in the file `/docs/openapi.json`. Please adjust openapi schema if you change the API.

### Useful links

- [Trakt API docs](https://trakt.docs.apiary.io/)
- [TMDB API docs](https://developers.themoviedb.org/3)
- [OpenAPI API docs](https://swagger.io/docs/specification/about/)
273 changes: 273 additions & 0 deletions settings/phpstorm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
<code_scheme name="Movary" version="173">
<option name="RIGHT_MARGIN" value="180" />
<PHPCodeStyleSettings>
<option name="COMMA_AFTER_LAST_PARAMETER" value="true" />
<option name="COMMA_AFTER_LAST_CLOSURE_USE_VAR" value="true" />
<option name="COMMA_AFTER_LAST_ARGUMENT" value="true" />
<option name="COMMA_AFTER_LAST_MATCH_ARM" value="true" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
<option name="ELSE_IF_STYLE" value="COMBINE" />
<option name="VARIABLE_NAMING_STYLE" value="CAMEL_CASE" />
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
<option name="BLANK_LINES_AROUND_CONSTANTS" value="1" />
<option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="0" />
<option name="SPACE_BEFORE_COLON_IN_RETURN_TYPE" value="true" />
<option name="NAMESPACE_BRACE_STYLE" value="2" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="0" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
<option name="BLANK_LINES_AROUND_FIELD" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<arrangement>
<groups />
<rules>
<section>
<rule>
<match>
<AND>
<CONST>true</CONST>
<visibility />
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PUBLIC>true</PUBLIC>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PROTECTED>true</PROTECTED>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PRIVATE>true</PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PUBLIC>true</PUBLIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PROTECTED>true</PROTECTED>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PRIVATE>true</PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<CONSTRUCTOR>true</CONSTRUCTOR>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<ABSTRACT>true</ABSTRACT>
<METHOD>true</METHOD>
<PUBLIC>true</PUBLIC>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<ABSTRACT>true</ABSTRACT>
<METHOD>true</METHOD>
<PROTECTED>true</PROTECTED>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<ABSTRACT>true</ABSTRACT>
<METHOD>true</METHOD>
<PRIVATE>true</PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<ABSTRACT>true</ABSTRACT>
<METHOD>true</METHOD>
<PUBLIC>true</PUBLIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<ABSTRACT>true</ABSTRACT>
<METHOD>true</METHOD>
<PROTECTED>true</PROTECTED>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<ABSTRACT>true</ABSTRACT>
<METHOD>true</METHOD>
<PRIVATE>true</PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<PUBLIC>true</PUBLIC>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<PROTECTED>true</PROTECTED>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<PRIVATE>true</PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<PUBLIC>true</PUBLIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<PROTECTED>true</PROTECTED>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<PRIVATE>true</PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>

0 comments on commit d60534e

Please sign in to comment.