/badge-backend

Badge JSON API which is build on top of Silex framework.

Primary LanguagePHPMIT LicenseMIT

What is this?

License GitHub version Dependency Status

Badge JSON API which is build on top of Silex framework.

Table of Contents

Main points

  • Configuration for each environment and/or developer
  • Authentication via JWT
  • "Automatic" API doc generation
  • Database connection (Doctrine dbal + orm)
  • Console tools (dbal, migrations, orm)
  • Basic API for badges
  • Basic API for badge groups
  • Basic API for images
  • And all the rest...

Requirements

  • PHP 5.5.x
  • Apache / nginx / IIS / Lighttpd see configuration information here

Development

  • Use your favorite IDE and get checkout from git
  • Open terminal, go to folder where you make that checkout and run following commands
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install

Installation

  • Open terminal and clone this repository to your server
  • Create web-server configuration which points to web folder

Configuration

Add your local.yml configuration file to some (or all) following directories:

  • resources/config/common
  • resources/config/dev
  • resources/config/prod

Within this file you can override any environment or common configuration value as you like. Basically first thing to do is define your database settings - without these you can't basically do anything...

Database initialization

This can be done with following command:

./bin/console migrations:migrate

Possible "failures"

  • Missing var directory? Create it and check that it has proper write access in other words just do chmod 777 var

Nice to know things

GET http://yoururl/_dump

  • generates pimple.json for autocomplete
  • See this for more info

./bin/console orm:convert:mapping --from-database --namespace="App\\Entities\\" annotation ./src

  • Generate Doctrine entities from database

Docker

This project has also Docker container that you can use. Actual Dockerfile uses php:5.5-cli as the base image.

You can easily build your own docker image with following command

docker build -t yourimage .

And after that run that docker image by following command

docker run -t -i yourimage

With this docker image you can set following ENV variables to specify your database connection:

DATABASE_DB_OPTIONS_DRIVER  
DATABASE_DB_OPTIONS_HOST    
DATABASE_DB_OPTIONS_DBNAME  
DATABASE_DB_OPTIONS_USER    
DATABASE_DB_OPTIONS_PASSWORD
DATABASE_DB_OPTIONS_CHARSET

Contributing

Please see the CONTRIBUTING.md file for guidelines.

Author

Tarmo Leppänen

LICENSE

The MIT License (MIT)

Copyright (c) 2016 Protacon Solutions