ingeniasoftware / luthier-ci

Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
https://luthier.ingenia.me/ci/en/
MIT License
151 stars 39 forks source link

Syntax error, unexpected '(' #6

Closed primapwd closed 6 years ago

primapwd commented 6 years ago

Hi, I get the following error:

A PHP Error was encountered Severity: 4096 Message: Argument 1 passed to Luthier\Route::getByUrl() must be an instance of Luthier\string, string given, called in E:\xampp\htdocs\apps\vendor\luthier\luthier\src\Hook.php on line 142 and defined Filename: src/Route.php Line Number: 374 Backtrace: File: E:\xampp\htdocs\apps\vendor\luthier\luthier\src\Route.php Line: 374 Function: _error_handler File: E:\xampp\htdocs\apps\vendor\luthier\luthier\src\Hook.php Line: 142 Function: getByUrl File: E:\xampp\htdocs\apps\index.php Line: 315 Function: require_once

A PHP Error was encountered Severity: Parsing Error Message: syntax error, unexpected '(' Filename: src/Middleware.php Line Number: 99 Backtrace:

Any ideas what caused the error?

andersonsalas commented 6 years ago

Hi! What version of PHP are you using?

primapwd commented 6 years ago

I'm using PHP 5.6.12 and CI version 3.1.8

andersonsalas commented 6 years ago

Thanks for report it. I've used some PHP 7 syntax and is not compatible with PHP 5.x. I'll fix that soon :man_facepalming:

primapwd commented 6 years ago

Hi, thanks for fixing PHP compatibility issue. I'm just wondering, does this works if I extend CI_Controller into MY_Controller and other controllers extend MY_Controller? Because all my routes always redirect to default_controller whatever route I set on web.php.

andersonsalas commented 6 years ago

It should work, since Luthier-CI retrieves the current framework singleton via &get_instance() function, no matters what class are using/extending for controllers.

Can you share your custom MY_Controller and your web.php route file? I'll try to reproduce the problem here.

primapwd commented 6 years ago

Well, maybe I missed something here. I have these two routes inside web.php.

Route::get('register', function() {
    echo "Register Here";
});

Route::get('/', function() {
    echo "Welcome";
});

Everytime I visit 'register', it's always showing 'Welcome' instead of 'Register Here'.

andersonsalas commented 6 years ago

It seems to be a problem while setting the current url during Luthier-CI boot

Edit: I've made an update: https://github.com/ingeniasoftware/luthier-ci/commit/dc23400f449e6a6388438c4f9d6c6d01c6361eb1 You can test if that solves the problem by using the 'dev-master' version of the repository:

composer require luthier/luthier "dev-master"

Let me know if that works :+1:

primapwd commented 6 years ago

Do you have apache mod rewrite enabled?

Yes, I do. I use .htaccess to remove index.php from url.

What is your 'uri_protocol' value in your config.php file?

This is my config.php $config['uri_protocol'] = 'REQUEST_URI';

I'll give it a try and let you know if that works. Thanks. :running_man:

primapwd commented 6 years ago

I've tried the dev-master version and it's works out of the box. :grin:

andersonsalas commented 6 years ago

Great! Stable version updated https://github.com/ingeniasoftware/luthier-ci/commit/dc23400f449e6a6388438c4f9d6c6d01c6361eb1

primapwd commented 6 years ago

Nice, I'll close this issue then. Thanks, dude. :grin: