Fork me on GitHub

1.1.1 Create your project

You can create a project in 3 ways:

  • create follow visual installation tutorial
  • create by cmd phalapi-buildapp
  • create manually

1.1.2 Create follow visual installation tutorial

Visit /path/to/PhalApi/Public/install on your browser after unpack PhalApi, for example:

http://dev.phalapi.com/install/

Then following the installation step by step:

Step 0: agree to install

a pic

Step 1: environment check

a pic

Step 2: system configure

a pic

Step 3: test api request

a pic

Step 4: finally

a pic

1.1.3 Create by cmd phalapi-buildapp

On linux, we can create a projects in serval seconds.

Firstly, we need to

$ chmod +x /path/to/PhalApi/PhalApi/phalapi-buildapp

Secondly,

$ cd /path/to/PhalApi
$ ./PhalApi/phalapi-buildapp MyApp

OK!

Then you can see a folder named MyApp at /path/to/PhalApi, it looks like:

$ cd MyApp/
$ tree
.
├── Api
│   └── Default.php
├── Common
├── Domain
├── Model
└── Tests
    ├── Api
    │   └── Api_Default_Test.php
    ├── Common
    ├── Domain
    ├── Model
    ├── phpunit.xml
    └── test_env.php

9 directories, 4 files

Meanwhile, here is an entrance under ./Public :

└── myapp
    ├── checkApiParams.php
    └── index.php

Finally, you can also visit it by:

http://dev.phalapi.com/myapp/

1.1.4 Create manually

On windowns, we can also create a project manually. It's easy to do this.

Assume our web root is: F:\xampp\htdocs\PhalApi

(1) Create an new project folder

For example, we create an MyApp project:
QQ截图20150404004219

Then add folder Api, Domain, Model, Common inside MyApp,
QQ截图20150404004458

(2) Prepare a API

All the API classes should be located at ./MyApp/Api , you can try to develop an simple API, or copy ./Demo/Api/Default.php to ./MyApp/Api/Default.php.

(3) Create entrance

In order to visit the API service, we need to add an entrance for MyApp,
QQ截图20150404004653

Please remmember to alter the app name in those tow file:

$vim ./Public/myapp/index.php
$vim ./Public/myapp/checkApiParams.php

QQ截图20150404004731

(4) Visit it!

Open the follow link on browser,

http://localhost/phalapi/public/myapp/

And you will see:
QQ截图20150404004959