Mini blog API is a RESTful API built on top of API Platform and Symfony 5.
Its purpose is to provide essential REST endpoints to start a blog application.
- Anyone can register to the application and see all blog posts.
- Only verified users can add and edit their blog posts.
- In order to become a verified blogger a user must go through a verification process controlled by platform admins.
Verification process :
- User initiates Verification Request by sending image of their ID and an optional message.
- Verification Request is flagged with status ‘Verification requested’.
- User can edit Verification Request until admin approves or declines it.
- Admin can see list of all Verification Requests and filter them by user and status. Admin can order them by date created.
- Admin can approve Verification Request and user will be granted access for adding new blog post. Verification Request is flagged with status ‘Approved’. User gets ‘Blogger’ role.
- Admin can decline Verification Request and add the reason for rejection. Verification Request is flagged with status ‘Declined’
- User will get an email notifying them if their request was approved or declined
Post fields :
titlecontentdate(Auto-generated / Immutable)
Users main fields :
emailfirstnamelastnamepasswordrole(ROLE_USER / ROLE_BLOGGER / ROLE_ADMIN)
VerificationRequest fields :
status(VERIFICATION_REQUESTED / VERIFICATION_APPROVED / VERIFICATION_DECLINED)date(Auto-generated / Immutable)messagerejectionReason
To install and run this app follow these instructions :
-
Clone the project
$ git clone https://github.com/gdalyy/mini-blog-app-api.git -
Install dependencies by running
$ composer updateunder project directory -
Update your
.envfile according to your preferences -
Generate SSH keys in order to use LexikJWTAuthenticationBundle and use the passphrase from your .env file
$ mkdir -p config/jwt $ openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096 $ openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout -
Create your database and migrate schema
$ php bin/console doctrine:database:create $ php bin/console doctrine:migrations:migrate -
If you want to load data fixtures
$ php bin/console doctrine:fixtures:loador simply run$ composer prepare -
And you're ready to GO ! launch local symfony web server
$ symfony serve
API documentation is now available under http://localhost:8000/api/docs , enjoy :)
PS: If some tests fail, this means probably that http://lorempixel.com/
used by Image Faker is down and not accessible.
So try to turn off tests related to /api/media_objects/ endpoints.
Behat
- copy the file
behat.xml.disttobehat.xml - Update your
.env.testfile according to your preferences - prepare testing environment by running
$ composer prepare-test - run tests
$ vendor/bin/behat
Phpunit
-
prepare testing environment by running
$ composer prepare-test -
To run a specific suite
$ bin/phpunit --testsuite unit $ bin/phpunit --testsuite integration $ bin/phpunit --testsuite functional -
To run all tests with coverage
$ bin/phpunit --coverage-html ./build