flight php 中文,PHP: composer的简单使用
安裝
$ sudo php -r "readfile('https://getcomposer.org/installer');" | php
$ sudo mv composer.phar /usr/local/bin/composer
使用
{
"name": "mikecao/flight",
"description": "Flight is a fast, simple, extensible framework for PHP. Flight enables you to quickly and easily build RESTful web applications.",
"homepage": "http://flightphp.com",
"license": "MIT",
"authors": [
{
"name": "Mike Cao",
"email": "mike@mikecao.com",
"homepage": "http://www.mikecao.com/",
"role": "Original Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"files": [ "flight/autoload.php", "flight/Flight.php" ]
},
"require-dev": {
"phpunit/phpunit": "~4.6"
}
}
注意 autoload。
$ cd /var/www/html
$ touch index.php
$ touch .htaccess
.htaccess內容如下:
RewriteEngine on
RewriteBase /
RewriteRule !\.(js|html|ico|gif|jpg|png|css)$ index.php
下載flight:
$ composer require mikecao/flight
看下目錄結構:
和index.php同一級的composer.json的內容如下:
{
"require": {
"mikecao/flight": "^1.2"
}
}
編寫index.php:
require 'vendor/autoload.php';
Flight::route('/', function(){
echo 'hello world!';
});
Flight::route('/foo', function(){
echo 'welcome to foo!';
});
Flight::start();
瀏覽器訪問http://127.0.0.1、http://127.0.0.1/foo可以看到效果。
修改composer.json后
$ composer install
# 或者
$ composer update
總結
以上是生活随笔為你收集整理的flight php 中文,PHP: composer的简单使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos7 php无法启动服务器,关
- 下一篇: php 上传 tmp_name 空,PH