2015-01-01 28 views
0

我跑裝載了localhost:8000/beauties支架「費爾康腳手架美女」,它加載罰款,但是當我點擊創建美女鏈接我收到以下錯誤:控制器處理程序類無法加載

BeautifyController handler class cannot be loaded 

我使用運行費爾康PHP的內置服務器:

php -S localhost:8000 -e -t public/ public/htrouter.php 

Htrouter.php

<?php 
if (!file_exists(__DIR__ . '/' . $_SERVER['REQUEST_URI'])) { 
    $_GET['_url'] = $_SERVER['REQUEST_URI']; 
} 
return false; 

BeautifyController:

<?php 

use Phalcon\Mvc\Model\Criteria; 
use Phalcon\Paginator\Adapter\Model as Paginator; 

class BeautiesController extends ControllerBase 
{ 

    /** 
    * Index action 
    */ 
    public function indexAction() 
    { 
     $this->persistent->parameters = null; 
    } 

    /** 
    * Searches for beauties 
    */ 
    public function searchAction() 
    { 

     $numberPage = 1; 
     if ($this->request->isPost()) { 
      $query = Criteria::fromInput($this->di, "Beauties", $_POST); 
      $this->persistent->parameters = $query->getParams(); 
     } else { 
      $numberPage = $this->request->getQuery("page", "int"); 
     } 

     $parameters = $this->persistent->parameters; 
     if (!is_array($parameters)) { 
      $parameters = array(); 
     } 
     $parameters["order"] = "id"; 

     $beauties = Beauties::find($parameters); 
     if (count($beauties) == 0) { 
      $this->flash->notice("The search did not find any beauties"); 

      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "index" 
      )); 
     } 

     $paginator = new Paginator(array(
      "data" => $beauties, 
      "limit"=> 10, 
      "page" => $numberPage 
     )); 

     $this->view->page = $paginator->getPaginate(); 
    } 

    /** 
    * Displayes the creation form 
    */ 
    public function newAction() 
    { 

    } 

    /** 
    * Edits a beautie 
    * 
    * @param string $id 
    */ 
    public function editAction($id) 
    { 

     if (!$this->request->isPost()) { 

      $beautie = Beauties::findFirstByid($id); 
      if (!$beautie) { 
       $this->flash->error("beautie was not found"); 

       return $this->dispatcher->forward(array(
        "controller" => "beauties", 
        "action" => "index" 
       )); 
      } 

      $this->view->id = $beautie->id; 

      $this->tag->setDefault("id", $beautie->id); 
      $this->tag->setDefault("title", $beautie->title); 
      $this->tag->setDefault("image", $beautie->image); 
      $this->tag->setDefault("content", $beautie->content); 

     } 
    } 

    /** 
    * Creates a new beautie 
    */ 
    public function createAction() 
    { 

     if (!$this->request->isPost()) { 
      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "index" 
      )); 
     } 

     $beautie = new Beauties(); 

     $beautie->title = $this->request->getPost("title"); 
     $beautie->image = $this->request->getPost("image"); 
     $beautie->content = $this->request->getPost("content"); 


     if (!$beautie->save()) { 
      foreach ($beautie->getMessages() as $message) { 
       $this->flash->error($message); 
      } 

      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "new" 
      )); 
     } 

     $this->flash->success("beautie was created successfully"); 

     return $this->dispatcher->forward(array(
      "controller" => "beauties", 
      "action" => "index" 
     )); 

    } 

    /** 
    * Saves a beautie edited 
    * 
    */ 
    public function saveAction() 
    { 

     if (!$this->request->isPost()) { 
      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "index" 
      )); 
     } 

     $id = $this->request->getPost("id"); 

     $beautie = Beauties::findFirstByid($id); 
     if (!$beautie) { 
      $this->flash->error("beautie does not exist " . $id); 

      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "index" 
      )); 
     } 

     $beautie->title = $this->request->getPost("title"); 
     $beautie->image = $this->request->getPost("image"); 
     $beautie->content = $this->request->getPost("content"); 


     if (!$beautie->save()) { 

      foreach ($beautie->getMessages() as $message) { 
       $this->flash->error($message); 
      } 

      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "edit", 
       "params" => array($beautie->id) 
      )); 
     } 

     $this->flash->success("beautie was updated successfully"); 

     return $this->dispatcher->forward(array(
      "controller" => "beauties", 
      "action" => "index" 
     )); 

    } 

    /** 
    * Deletes a beautie 
    * 
    * @param string $id 
    */ 
    public function deleteAction($id) 
    { 

     $beautie = Beauties::findFirstByid($id); 
     if (!$beautie) { 
      $this->flash->error("beautie was not found"); 

      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "index" 
      )); 
     } 

     if (!$beautie->delete()) { 

      foreach ($beautie->getMessages() as $message) { 
       $this->flash->error($message); 
      } 

      return $this->dispatcher->forward(array(
       "controller" => "beauties", 
       "action" => "search" 
      )); 
     } 

     $this->flash->success("beautie was deleted successfully"); 

     return $this->dispatcher->forward(array(
      "controller" => "beauties", 
      "action" => "index" 
     )); 
    } 

} 

的.htaccess:

AddDefaultCharset UTF-8 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] 
</IfModule> 

任何想法?

+0

我想查看查看代碼。你說這發生在你點擊創建時,所以我們需要知道該鏈接認爲它會發生什麼。 –

回答

2

在你的BeautifyController.php文件中,controllername不是BeautifyController,而是BeautiesController。 我認爲這是你的問題。

也許如果您告訴我們您在Phalcon路由中還做了什麼,我們可能會進一步提供幫助。

+0

這不是幫助了 –

相關問題