A Symfony project created on April 2, 2017, 4:00 pm.
A basic api with symfony 3.2, lexik jwt, nelmio, jms, fosrest This API allow you to connect and manage user
- composer
- openssl
- php >= 7.0.0
- ftp
$> composer install
$> php bin/console doctrine:database:create --if-not-exists
$> php bin/console doctrine:schema:update --force
$> php bin/console doctrine:fixtures:load
$> mkdir -p var/jwt # For Symfony3+, no need of the -p option
$> openssl genrsa -out var/jwt/private.pem -aes256 4096
$> openssl rsa -pubout -in var/jwt/private.pem -out var/jwt/public.pem
parameter.yml
parameters:
database_host: 127.0.0.1 #db info
database_port: 3306 #db info
database_name: basic-api #db info
database_user: root #db info
database_password: root #db info
mailer_transport: gmail
mailer_host: 127.0.0.1
mailer_user: [email protected]
mailer_password: d1zqvdzz
mailer_address: "[email protected]"
secret: ThisTokenIsNotSoSecretChangeIt
jwt_private_key_path: '%kernel.root_dir%/../var/jwt/private.pem'
jwt_public_key_path: '%kernel.root_dir%/../var/jwt/public.pem'
jwt_key_pass_phrase: basic-api
jwt_token_ttl: 3600
basic_api.ftp_path: 127.0.0.1 #ftp_info
basic_api.ftp_login: login #ftp_info
basic_api.ftp_password: password #ftp_info
If you want to use ftp function like avatar upload you should launch a ftp server.
For launching it locally
$> ftp localhost
Then for login : a user from your computer and his password.
And change the parameter file consequently
$> php bin/console server:run
$> ./bin/console debug:router
Unit test are running with phpunit, you can find a php7 executable of phpunit in bin/
$> php bin/console doctrine:database:create --env=test --if-not-exists
$> php bin/console doctrine:schema:update --force --env=test
$> php bin/console doctrine:fixtures:load --env=test
$> php bin/phpunit
The documentation is generated using the NelmioApiDocBundle. Access the documentation at http://localhost:8000/api/doc
You can connect to the api by POST on http://localhost:8000/api/auth the parameters are : [username => your_login, password => your_password] (two based user are already in database in ORM fixtures, with username:ileo-admin password:admin and username:ileo-user password:user)
For further details, read the documentation about JsonWebToken.
Read your api doc to learn what you can do with the API