On the basis of Part1, add a route for the project:
Edit Composer.json File:
{"Require": {"Codingbean/macaw": "Dev-master"}}
Save, and execute:
Composer.phar Update
At this time, vendor more Codingbean folder
Mkdir/opt/htdocs/mffc/public Mkdir/opt/htdocs/mffc/config
New route file:routes.php
vi/opt/htdocs/mffc/public/routes.php
Save the following content:
<?php/** * Routes Routing rules * @author jceee */use \noahbuscher\macaw\macaw; Macaw::get ('/', function () {echo ' Hello world! ';}); Macaw::get ('/(:) ', function ($slug) {echo ' The slug is: '. $slug;}); Macaw::p ost ('/', function () {echo ' I <3 post commands! ';}); Macaw::error (function () {echo ' 404:: Not Found ';}); Macaw::d ispatch ();?>
Create a portal file index.php:
vi/opt/htdocs/mffc/public/index.php
Save the following content:
<?php/** * @author Chenjie *///auto-load require_once (dirname (__file__). ‘/.. /vendor/autoload.php ');//Routing Configuration require_once (DirName (___file__). ‘/.. /config/routes.php ');?>
When the browser accesses the public/index.php under your project file, the following Hello world! appears, then the route extension is completed
Hello world!
#[composer Learning Note]part2: adding routes