Welcome Guest, Not a member yet? Register   Sign In
[split] appstarter doesn't work (CodeIgniter 4.0.0-beta.3 released)
#1

I just tried out the codeigniter4/appstarter and it doesn't work "out of the box". I'd report it on GitHub but the project repo doesn't have an issue tracker.

The problem is simple to fix - it ships with the DebugToolbar enabled in app/Config/Filters.php.

PHP Code:
    // Makes reading things below nicer,
    // and simpler to change out script that's used.
    
public $aliases = [
        
'csrf'     => \CodeIgniter\Filters\CSRF::class,
        
'toolbar'  => \CodeIgniter\Filters\DebugToolbar::class,
        
'honeypot' => \CodeIgniter\Filters\Honeypot::class,
    ];

    
// Always applied before every request
    
public $globals = [
        
'before' => [
            
//'honeypot'
            // 'csrf',
        
],
        
'after'  => [
            
'toolbar',
            
//'honeypot'
        
],
    ]; 

The toolbar needs to be commented out in $globals['after'] like so:


PHP Code:
    // Always applied before every request
    
public $globals = [
        
'before' => [
            
//'honeypot'
            // 'csrf',
        
],
        
'after'  => [
            
//'toolbar',
            //'honeypot'
        
],
    ]; 

Just thought I'd post this for anyone wondering why the appstarter doesn't work out-of-the-box.
Reply
#2

What problem are you experiencing?
Reply
#3

Thanks for your reply. It isn't really a "problem", easily worked around but it could be off-putting to someone trying the framework out. I thought I had supplied sufficient detail in my earlier post but I'll post the error log here for completeness:

Quote:CRITICAL - 2019-05-17 12:39:38 --> Class 'CodeIgniter\Filters\DebugToolbar' not found
#0 /home/alex/projects/ci4/vendor/codeigniter4/framework/system/CodeIgniter.php(343): CodeIgniter\Filters\Filters->run('/', 'after')
#1 /home/alex/projects/ci4/vendor/codeigniter4/framework/system/CodeIgniter.php(235): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#2 /home/alex/projects/ci4/public/index.php(45): CodeIgniter\CodeIgniter->run()
#3 {main}

This is a fresh install using composer (composer create-project codeigniter4/appstarter ci4 -s beta) and running on PHP 7.2 with all dependencies met. I can test with other PHP versions if you like.

I notice that "vendor/codeigniter4/framework/application/Filters/DebugToolbar.php" has a namespace of "App\Filters" while "app/Config/Filters.php" uses "\CodeIgniter\Filters\DebugToolbar::class" as shown in the first code snippet in my earlier post.
Reply
#4

Hmm - something hinky here.
"vendor/codeigniter4/framework/application/Filters/DebugToolbar.php" should not exist - that looks like an old remnant, before the "application" folder was renamed "app", and the DebugToolbar was moved from app/ to system/.
I have found that I need to do a "composer update" after creating a new project with the appstarter, to get everything fully up-to-date.
Reply
#5

Excellent - yes, running composer update fixes the missing \CodeIgniter\Filters\DebugToolbar class. As to why this is necessary, I had a quick look at the source of the appstarter composer.lock file:

Code:
           "name": "codeigniter4/framework",
           "version": "v4.0.0-alpha.4",
           "source": {
               "type": "git",
               "url": "https://github.com/codeigniter4/framework.git",
               "reference": "1743947311c517a7b28094a34500c46e29309ccf"
           },
[...]
As you can see, the CodeIgniter famework is locked at v4.0.0-alpha.4, making it necessary to run composer update. The composer.json file was updated in the release commit but the composer.lock file was not. Future releases could have a new lock file committed, or the documentation for installation could be updated to ask the end-user to run composer update even on a new install. I'll send a pull request to update the documentation, in case that is the preferred solution.
Reply
#6

Well, that was more work than I expected (I had to update Sphinx to version 1.8.0 on Debian to get the documentation to build) but I have sent a pull request as promised.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB