lonnieezell / Bonfire2

CodeIgniter 4-based application skeleton
MIT License
131 stars 50 forks source link

New install not work (it break php spark and default welcome CI page) #342

Open jinbatsu opened 1 year ago

jinbatsu commented 1 year ago

I have try with fresh install from installation guide which I did: Info: I'm using MAMP in Mac.

which php
# rerturned /Applications/MAMP/bin/php/php8.2.0/bin//php
composer create-project codeigniter4/appstarter my-app

I check the web (from browser) is working as default CI 4 welcome page. and the Environment is production.

Next step:

cd my-app
composer config minimum-stability dev
composer config prefer-stable true

Then:

~/S/p/my-app ❯❯❯ composer require lonnieezell/bonfire:dev-develop
./composer.json has been updated
Running composer update lonnieezell/bonfire
Loading composer repositories with package information
Updating dependencies
Lock file operations: 6 installs, 0 updates, 0 removals
  - Locking codeigniter4/settings (v2.1.1)
  - Locking codeigniter4/shield (dev-develop 22443d0)
  - Locking components/font-awesome (6.2.0)
  - Locking lonnieezell/bonfire (dev-develop 7de4a16)
  - Locking roave/security-advisories (dev-latest d1af114)
  - Locking tatter/alerts (v3.1.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
  - Installing codeigniter4/settings (v2.1.1): Extracting archive
  - Installing tatter/alerts (v3.1.0): Extracting archive
  - Installing roave/security-advisories (dev-latest d1af114)
  - Installing components/font-awesome (6.2.0): Extracting archive
  - Installing codeigniter4/shield (dev-develop 22443d0): Extracting archive
  - Installing lonnieezell/bonfire (dev-develop 7de4a16): Extracting archive
Generating optimized autoload files
30 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
~/S/p/my-app ❯❯❯ 

Next step:

~/S/p/my-app ❯❯❯ php spark bf:install

Fatal error: Uncaught Error: Undefined constant "ENVIRONMENT" in /Users/jinbatsu/Sites/prod/my-app/vendor/codeigniter4/framework/system/Common.php:806
Stack trace:
(...)
~/S/p/my-app ❯❯❯

It break the php spark command. And accesing from browser is not working, it is blank white page. The php spark from CI4 works normally before including bonfire. Additional info: Using PHP 8.2 and intl is loaded.

What is the cause of this?

projectwehelp commented 1 year ago

having the exact same issue

lonnieezell commented 1 year ago

Looks like the current workaround until a fix is released is to add an app/Modules directory. It can be empty.

lonnieezell commented 1 year ago

@jinbatsu @projectwehelp I believe the issue should be fixed now. Can you give it another try and let me know for sure?

projectwehelp commented 1 year ago

confirmed , it's working perfectly now ! Thank you

dgvirtual commented 1 year ago

@lonnieezell , looks like I did not add the proper checks for directory to exist when adding app modules namespaces autodiscovery. Sorry, have to be more careful.

lonnieezell commented 1 year ago

@dgvirtual no worries. The real issue seemed to be using log_message at that point. I didn't trace it all the back but it seems that was being called before ENVIRONMENT constant had been defined and log_message was checking that.

jinbatsu commented 1 year ago

@lonnieezell, OK it works but with error Shield required csrfProtection using session not cookie, so after I change and set like this:

security.csrfProtection = 'session' 
security.tokenRandomize = false
security.tokenName = 'csrf_token_xxx'
security.headerName = 'X-CSRF-TOKEN'
security.cookieName = 'csrf_cookie_xxx'
security.expires = 7200
security.regenerate = true
security.redirect = false
security.samesite = 'Lax'

It works.. Thank you!