我试图从AuthController扩展ControllerBase类但是会发生这种情况:致命错误:Class' ControllerBase'在第3行找不到C:\ xampp \ htdocs \ tc \ app \ controllers \ IndexController.php。
ControllerBase.php
<?php
use Phalcon\Mvc\Controller;
class ControllerBase extends Controller {
public function onConstruct() {
}
}
AuthController.php
<?php
class AuthController extends ControllerBase {
public function indexAction()
{
}
}
有问题吗?我使用PhpStorm并从C:\ phalcon-devtools-master \ ide \ stubs \ Phalcon
添加了ExternalLibraries你能帮忙解决这个问题吗?
谢谢,Razvan!
答案 0 :(得分:0)
可能是#include <iostream>
#include <string>
using namespace std;
void calculateCarpetSize (int length, int width)
{
float carpetSize = (length * width);
cout.setf(ios::fixed);
cout.precision(0);
}
void calculateCarpetPrice (float carpetSize, float sellingPrice )
{
float carpetPrice = ( carpetSize * sellingPrice );
}
void calculateCarpetCost (float carpetSize, float sellingPrice )
{
float salesTax = 0.14;
float carpetCost = (carpetSize * sellingPrice * salesTax);
cout.precision(2);
}
void calculateLabourCost ( float carpetSize, float labour)
{
labour = 24.00;
float labourCost = carpetSize * labour;
}
bool qualifyForDiscount (int customerNumber)
{
if ( customerNumber < 99999)
{
void computeDiscount (float carpetCost);
return true;
}
else
{
return false;
}
}
void computeDiscount (float carpetCost, float discountPercentage)
{
cout << "Enter the percentage discount ." << endl;
cin >> discountPercentage;
float carpetCostDiscount = carpetCost * discountPercentage;
}
void printCustomerStatement( )
{
cout.setf(ios::fixed);
cout << endl;
cout << "CROSWELL CARPET STORE" << endl;
cout << "STATEMENT" << endl;
}
int main()
{
int customerName;
int customerSurname;
int customerNumber;
float carpetSize;
float carpetPrice;
float sellingPrice;
float salesTax = 0.14;
float labourCost;
int labour = 24.00;
float length;
float width;
float discount;
float discountPercentage;
cout.setf(ios::fixed);
cout.precision(2);
cout << "Please enter the information" << endl;
cout << "Enter the customer's first name: " << endl;
cin >> customerName;
cout << "\n Enter customers surname: " << endl;
cin >> customerSurname;
cout << "\n The length of the room: " << endl;
cin >> length;
cout << "\n Enter the width of the room: " << endl;
cin >> width;
cout << "\n Enter the carpet selling price: " << endl;
cin >> sellingPrice;
int printCustomerStatement;
{
cout << "\n Customer name : " << endl;
cin >> customerName >> customerSurname ;
cout << "Customer number : " << endl;
cin >> customerNumber;
cout << "\n Carpet price : " << endl;
cin >> carpetPrice;
cout << "Labour : " << endl;
cin >> labour;
cout << "\n Subtotal : " << endl;
cin >> carpetPrice;
cout << "Less Discount : " << endl;
cin >> qualifyForDiscount;
cout << "\n Subtotal: " <<endl;
cin >> carpetPrice;
cout << "Plus tax: " << endl;
cin >> salesTax;
cout << "Total: " << endl;
cin >> carpetPrice;
}
return 0;
}
在示例中显示“ControllerBase”,如果使用“使用Phalcon \ Mvc \ Controller;”
在phalcon中不存在ControllerBase
答案 1 :(得分:0)
尝试使用名称空间并使用Phalcon loader注册它们。
例如在ControllerBase中:
namespace \Base\Frontend\Controllers;
use \Phalcon\Mvc\Controller;
class ControllerBase extends Controller;
在IndexController中:
namespace \Base\Frontend\Controllers;
class IndexController extends ControllerBase;
并在服务或模块配置中添加:
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'Base\Frontend\Controllers' => __DIR__ . '/controllers/'
));
$loader->register();
其中__DIR__。 &#39; /控制器/&#39;是控制器目录的路径。