rapidPHP 1.1.0 - 建立第一個app

來源:互聯網
上載者:User

標籤:base   建立   end   路徑   pre   ons   use   on()   str   

建立controller

 

在application/目錄下建立controller目錄,然後接著在controller目錄下建立BaseController,繼承Controller //注:BaseController作用是全域controller公用方法庫

檔案名稱:BaseController.class.php

<?phpnamespace application\controller; use rapid\core\Controller;use rapid\library\rapid; class BaseController extends Controller{    //公用方法庫}

 

接著建立IndexController,繼承BaseController

<?phpnamespace application\controller;use rapid\library\rapid; class IndexController extends BaseController{    public function indexAction()
  {
    echo "RapidPHP 架構";
  }}

簡單的控制前就建立完畢了,下面配置路由,找到 rapid/config/routing/ 目錄,裡面有兩個檔案

app.inc.php //控制器方法配置,允許路由調用的的方法,不允許的則不要配置

<?phpnamespace rapid\config\routing;use application\controller\IndexController;use rapid\config\constants\App;use rapid\config\constants\app\Routing;/** * 可以訪問的類,介面,不聲明則沒許可權訪問 */return array(    IndexController::class => array(        ‘indexAction‘ => array(            Routing::METHOD_TYPE => App::APP_REQUEST_GET, //請求類型get請求        ),    ));

 

uri.inc.php //路由地址配置

<?phpnamespace rapid\config\routing;use application\controller\IndexController;use rapid\config\constants\app\Routing;/** * 路由uri配置層一層外下匹配,直到匹配到停止 * 正則或路徑=>類,app.inc的對應類的元素名 */return array(    ‘/^(\/|index)(|\.htm|\.html|\.php)$/‘ => array(        Routing::CLASS_NAME => IndexController::class, Routing::APP_NAME => ‘indexAction‘    ), );

 

ok,訪問 / /index /index.htm /index.html /index.php 都可以訪問進去,致次,我們的第一個rapidPHP App就建立完畢了。 

 

rapidPHP 1.1.0 - 建立第一個app

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.