Tediace
Tediace

Reputation: 1

i was execute phalcon (php) on xampp but i got messages "Wrong number of parameters"

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}

this is my code router

<?php

$router = $di->getRouter();

// Define your routes here

$router->handle(isset($_GET['_url']) ? $_GET['_url'] : '');

controller

<?php

use Phalcon\Mvc\Controller;

class ControllerBase extends Controller
{

}

my full code 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();
}

Upvotes: 0

Views: 342

Answers (2)

Ken Grammer
Ken Grammer

Reputation: 86

I use this in my index.php:

/**
 * Handle the request
 */
$application = new Phalcon\Mvc\Application($di);
$response = $application->handle($_SERVER["REQUEST_URI"]);
$response->send();

YMMV...

Upvotes: 0

Chess
Chess

Reputation: 36

Check your phalcon version. In phalcon v3 your handle method hasn't any param, but from version 4 you must to include your URL:

public function handle( string $uri ): ResponseInterface | bool

So, you can write:

$router->handle(isset($_GET['_url']) ? $_GET['_url'] : '');

Upvotes: 0

Related Questions