This repo is a purified empty application to build Restful APIs based on Yii2 framework. You can find a lot of documentation related to this framework, and the best place to start is maybe their official documentation. This repo contains the minimal structure for an API application with the appropriate configuration already written and working. Without any database, you can still use the HelloController
to get some dummy Hello World message
.
- Download composer:
curl -s https://getcomposer.org/installer | php
- Create a new project based on this one
composer.phar create-project pingu1/yii2-minimal-api api
- Init the Git repository in your new project
git init
The default setup to server Yii2 projects are also valid for this application. Please read the documentation to setup your Apache or Nginx server.
The code is structured as such:
api
-- commands
-- common
---- controllers
---- models
-- config
-- modules
---- v1
------ controllers
------ models
-- runtime
-- tests
-- web
vendor
- The
api
directory is basically the root of your application - The
commands
folder contains all the console scripts - The
common
directory contains all models and controllers that could be shared between different versions of your api - The
modules
directory will contain the different versions of your api - The
runtime
directory will stores cache and log files generated during runtime - The
tests
directory will contain all your test files (Yii2 runs with Codeception) - The
web
directory only contains the entry script of your api
Once your webserver up and ready, you should be able to access the following urls: