[英]i was execute phalcon (php) on xampp but i got messages "Wrong number of parameters"
參數數量錯誤 #0 C:\xampp1\htdocs\crud_by_phalcon\app\config\router.php(7): Phalcon\Mvc\Router->handle() #1 C:\xampp1\htdocs\crud_by_phalcon\public\index .php(20): include('C:\xampp1\htdoc...') #2 {main}
這是我的代碼路由器
<?php
$router = $di->getRouter();
// Define your routes here
$router->handle(isset($_GET['_url']) ? $_GET['_url'] : '');
控制器
<?php
use Phalcon\Mvc\Controller;
class ControllerBase extends Controller
{
}
我的完整代碼 index.php
<?php
use Phalcon\Di\FactoryDefault;
error_reporting(E_ALL);
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');
try {
/**
* The FactoryDefault Dependency Injector automatically registers
* the services that provide a full stack framework.
*/
$di = new FactoryDefault();
/**
* Handle routes
*/
include APP_PATH . '/config/router.php';
/**
* Read services
*/
include APP_PATH . '/config/services.php';
/**
* Get config service for use in inline setup below
*/
$config = $di->getConfig();
/**
* Include Autoloader
*/
include APP_PATH . '/config/loader.php';
/**
* Handle the request
*/
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
// $response = $application->handle();
// $response->send();
} catch (\Exception $e) {
echo $e->getMessage();
}
檢查您的 phalcon 版本。 在 phalcon v3 中,您的 handle 方法沒有任何參數,但從版本 4 開始,您必須包含您的 URL:
public function handle( string $uri ): ResponseInterface | bool
所以,你可以寫:
$router->handle(isset($_GET['_url']) ? $_GET['_url'] : '');
我在我的 index.php 中使用它:
/**
* Handle the request
*/
$application = new Phalcon\Mvc\Application($di);
$response = $application->handle($_SERVER["REQUEST_URI"]);
$response->send();
YMMV...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.