This is the API for API as a Service.
With API as a Service you can easily build PHP APIs via a GUI.
If you want to try out our application quickly in the cloud, you can set it up as a workspace in Gitpod. Otherwise, please continue reading.
- Docker and Docker Compose
- Docker Sync if you want to develop at full speed on OSX or Windows (Optional)
Application configuration is stored in .env
file.
You can change application environment to dev
of prod
by changing APP_ENV
variable in .env
file.
An app
database is created by default with user app
and password app
. root password is app
.
To start the docker containers execute:
docker-compose up
If you want to use Docker Sync
on OSX or Windows you can execute the command below from your OSX- or WSL-Console instead:
docker-sync-stack start
docker-compose exec php composer install
If composer runs out of memory when doing this the first time you should run
docker-compose exec -e COMPOSER_MEMORY_LIMIT=-1 php composer install
docker-compose exec php openssl genrsa -out config/jwt/private.pem -aes256 4096
docker-compose exec php openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
Don't forget to update JWT_PASSPHRASE
in .env
file. By default it's app!
Update database credentials in .env
and deploy schema:
docker-compose exec php php bin/console doctrine:migrations:migrate --no-interaction
If you want to modify the entities, don't forget to run:
docker-compose exec php php bin/console doctrine:migrations:diff
If you want to load the fixtures run:
docker-compose exec php php bin/console doctrine:fixtures:load --no-interaction
You should create an administrator account:
docker-compose exec php php bin/console acl:create-user EMAIL PASSWORD --admin
You can retrieve an JWT Access Token by posting your credentials to /auth/login_check
:
curl -X POST -H "Content-Type: application/json" http://localhost/auth/login_check \
-d '{ "email" : "EMAIL", "password" : "PASSWORD" }'
If your credentials are correct the server should respond with an JWT Access Token:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOcm9sZXMiOlsiUk9MRV9..."
}
Do not forget to send an Authorization
HTTP-Header when requesting /aaas
resources and set the value to Bearer YOUR_TOKEN
. You get an 401 Unauthorized Error
otherwise. See more information about that in our Wiki.
For Swagger UI open https://localhost/docs in your browser.
Please note that Swagger UI is disabled when you set APP_ENV
to prod
in .env
.
It is recommended to add short aliases for the following frequently used container commands:
docker-compose exec php /bin/bash
to run a shell inside the php containerdocker-compose exec php php
to run php in containerdocker-compose exec php php bin/console
to run Symfony CLI commandsdocker-compose exec php php bin/console cache:clear
to clear cachedocker-compose exec php composer update
to update composer dependenciesdocker-compose exec mariadb mysql -u app -p app
to run MySQL commands
Our test suite uses an app_test
database whose container service can be viewed under mariadb_test
in docker-compose.yml
. You should run the commands below to populate this database with our schema and to load the data fixtures if you want to run the tests.
docker-compose exec php php bin/console doctrine:migrations:migrate --no-interaction --env=test
docker-compose exec php php bin/console doctrine:fixtures:load --no-interaction --env=test
The test environment uses another SSL key pair. Do not forget to generate it. Add -passout pass:app!
when generating the private key and -passin pass:app!
when generating the public key if you want to skip interaction.
docker-compose exec php openssl genrsa -out config/jwt/private-test.pem -aes256 4096
docker-compose exec php openssl rsa -pubout -in config/jwt/private-test.pem -out config/jwt/public-test.pem
If you want to run the testsuite execute the command below:
docker-compose exec php php bin/phpunit -c config/ci/phpunit.xml.dist
docker-compose exec php php vendor/bin/phpcs --report=xml --report-file=build/ci/phpcs.xml --standard=config/ci/phpcs.xml.dist
docker-compose exec php php bin/phpunit -c config/ci/phpunit.xml.dist --coverage-html build/ci/coverage
docker-compose exec php php vendor/bin/phpmd src/ html config/ci/phpmd.xml.dist --reportfile build/ci/phpmd.html
docker-compose exec php php vendor/bin/pdepend --summary-xml=build/ci/php-pdepend.xml \
--jdepend-chart=build/ci/php-jdepend.svg --overview-pyramid=build/ci/php-pyramid.svg \
--ignore=src/Migrations/ src/
Visit our Wiki to familiarize yourself with the possibilities of AaaS API.