zokirov / api-starter-kit
API starter kit for Symfony projects
This package's canonical repository id has changed and the package has been frozen as a result.
1.5.5
2025-05-03 16:43 UTC
Requires
- php: >=8.2
- ext-ctype: *
- ext-iconv: *
- api-platform/doctrine-orm: ^4.1.7
- api-platform/symfony: ^4.1.7
- doctrine/dbal: ^3.9.4
- doctrine/doctrine-bundle: ^2.14
- doctrine/doctrine-migrations-bundle: ^3.4.1
- doctrine/orm: ^3.3.3
- lexik/jwt-authentication-bundle: ^3.1.1
- nelmio/cors-bundle: ^2.5
- phpdocumentor/reflection-docblock: ^5.6.2
- phpstan/phpdoc-parser: ^2.1
- symfony/asset: 7.2.*
- symfony/console: 7.2.*
- symfony/dotenv: 7.2.*
- symfony/expression-language: 7.2.*
- symfony/flex: ^2.5
- symfony/framework-bundle: 7.2.*
- symfony/property-access: 7.2.*
- symfony/property-info: 7.2.*
- symfony/runtime: 7.2.*
- symfony/security-bundle: 7.2.*
- symfony/serializer: 7.2.*
- symfony/twig-bundle: 7.2.*
- symfony/validator: 7.2.*
- symfony/yaml: 7.2.*
Requires (Dev)
- symfony/maker-bundle: ^1.63
Conflicts
This package is not auto-updated.
Last update: 2025-05-18 11:16:28 UTC
README
[//]: <> ( todo udpate image and add new docker commands, tell about interfaces )
Starter kit for API with Symfony, Doctrine, Maker Bundle, Migration Bundle, Api-Platform and JWT-auth.
Kit has also already created a User entity with all crud routes
Kit has 3 docker containers: php, nginx and mysql
Installation
Download the project
Go to the project directory<br>
```cd api-starter-kit```
Run docker containers <br>
```docker compose up -d```
Install composer scripts:<br>
```docker compose exec php composer install```
To install project run command:<br>
```docker compose exec php bin/console ask:install```
**Done! You can open <a href="http://localhost:8508/api" target="_blank">http://localhost:8508/api</a> via browser.
By the way, you can change this port by changing ```DOCKER_NGINX_PORT``` variable in [.env](.env) file.**
## Docker
For enter to php container run
```docker compose exec php bash```
For enter to mysql container run
```docker compose exec mysql bash```
For enter to nginx container run
```docker compose exec nginx bash```
You can change containers prefix by changing ```DOCKER_PROJECT_NAME``` variable in [.env](.env) file.
Also, you can change public ports of nginx and mysql by changing ```DOCKER_NGINX_PORT``` and ```DOCKER_DATABASE_PORT```
Database allows connections only from localhost.
Because of this, when you use the project in production and want to connect to a database from your computer,
you should connect via ssh bridge.
## Cron
You can use [docker/php/cron-file](docker/php/cron-file) for cron jobs.
After you must re-build php container by running command:<br>
```docker compose up -d --build```
## Swagger
You can change the project name and description on swagger by editing file
[config/packages/api_platform.yaml](config/packages/api_platform.yaml)
## Git Hook
If you don't use any deploying system, you can do <br>
```cp docker/other-files/git/hooks/post-merge .git/hooks```
In this way git always executes command ```bin/console ask:deploy```.
You can change this command in the file [src/Command/AskDeployCommand.php](src/Command/AskDeployCommand.php).
This command will install requirements via composer,
clear caches, change an owner of ./var and ./public/media folders to www-data, will run migrations.
## JWT keys
To use the JSON Web Token system, you must create private and public keys.
They have already created when you install a project. You can re-create them with:<br>
```bin/console ask:generate:jwtKeys```