pingu1/yii2-minimal-api

Yii 2 Minimal API template

1.1 2017-06-16 12:29 UTC

This package is not auto-updated.

Last update: 2024-05-12 02:35:54 UTC


README

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.

Installation

  1. Download composer: curl -s https://getcomposer.org/installer | php
  2. Create a new project based on this one composer.phar create-project pingu1/yii2-minimal-api api
  3. Init the Git repository in your new project git init

Setting up your web server

The default setup to server Yii2 projects are also valid for this application. Please read the documentation to setup your Apache or Nginx server.

Code structure

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

Simple Hello World

Once your webserver up and ready, you should be able to access the following urls: