/api-symfony3

Blog API Backend

Primary LanguagePHPMIT LicenseMIT

Hip Hip Array API

Security Check

php bin/console security:check

Symfony show all routes

php bin/console debug:router

Symfony clear cache

bin/console cache:clear --no-debug --env=prod
bin/console cache:clear --no-debug --env=dev

Database

Build database

sudo -u www-data bin/console doctrine:migrations:status
sudo -u www-data bin/console doctrine:migrations:migrate

Load fixtures

bin/console doctrine:fixtures:load -n --env=dev

Rebuild database

bin/console Hip:rebuild_database --runtests dev

Routes

Public Pages

Secure Pages

Admin Pages

Testing Setup

install phantomjs

cd bin/phantomjs
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2
cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
chmod +x /usr/local/bin/phantomjs

start/stop phantomjs

bin/phantomjs/start.sh

Config

cp codeception.yml.dist codeception.yml

Run build after updating yml files (eg. adding a module to unit.suite.yml)

vendor/codeception/codeception/codecept build

Running Tests

vendor/bin/codecept run unit
vendor/bin/codecept run api

Register test with Postman

POST

Headers

  • Accept application/json
  • Content-Type application/json

Body (raw)

{"email":"test@example.com","username":"tester","plainPassword":{"first":"password","second":"password"}}

Json Web Token Authentication

SSH keys

Generate SSH keys

$ mkdir -p app/var/jwt
$ openssl genrsa -out app/var/jwt/private.pem -aes256 4096
$ openssl rsa -pubout -in app/var/jwt/private.pem -out app/var/jwt/public.pem

Get the token

POST

Headers

  • Accept application/json
  • Content-Type application/json

Body (raw)

{"_username":"tester","_password":"password"}

Use the token

GET

Headers

  • Accept application/json
  • Content-Type application/json
  • Authorization Bearer {token}

API Docs

http://api.hiphiparray.dev/doc

Authentication Notes

Packages

friendsofsymfony/rest-bundle

jms/serializer-bundle

nelmio/api-doc-bundle

doctrine/doctrine-migrations-bundle

willdurand/hateoas-bundle

friendsofsymfony/user-bundle

lexik/jwt-authentication-bundle

flow/jsonpath

doctrine/doctrine-fixtures-bundle

codeception/codeception

nelmio/cors-bundle