2017 © Pedro Peláez
 

project yii2-minimal-api

Yii 2 Minimal API template

image

pingu1/yii2-minimal-api

Yii 2 Minimal API template

  • Friday, June 16, 2017
  • by pingu1
  • Repository
  • 2 Watchers
  • 3 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 29 % Grown

The README.md

Basic Yii2 API application

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., (*1)

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., (*2)

Code structure

The code is structured as such:, (*3)

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: - http://127.0.0.1/v1/hello - http://127.0.0.1/v1/hello/you, (*4)

The Versions