corcel / corcel

Use WordPress backend with Laravel or any PHP application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing PhpOption\Option dependencies on CakePHP

mehov opened this issue · comments

commented
  • Corcel Version: 6.0.0
  • Framework Name & Version: CakePHP 4.4
  • PHP Version: 8.0.26

Description:

I required jgrossi/corcel on a fresh install of CakePHP. I didn't even get to actually using any of the corcel classes. The base application stopped working throwing the below error:

PHP message: PHP Fatal error: Uncaught Error: Class "PhpOption\Option" not found in /var/www/example/vendor/illuminate/support/Env.php:76
Stack trace:
0 /var/www/example/vendor/illuminate/support/helpers.php(137): Illuminate\Support\Env::get()
1 /var/www/example/config/app.php(19): env()
2 /var/www/example/vendor/cakephp/cakephp/src/Core/Configure/Engine/PhpConfig.php(89): include('...')
3 /var/www/example/vendor/cakephp/cakephp/src/Core/Configure.php(341): Cake\Core\Configure\Engine\PhpConfig->read()
4 /var/www/example/config/bootstrap.php(81): Cake\Core\Configure::load()
5 /var/www/example/vendor/cakephp/cakephp/src/Http/BaseApplication.php(173): require_once('...')
6 /var/www/example/src/Application.php(47): Cake\Http\BaseApplication->bootstrap()
7 /var/www/example/vendor/cakephp/cakephp/src/Http/Server.php(109): App\Application->bootstrap()
8 /var/www/example/vendor/cakephp/cakephp/src/Http/Server.php(79): Cake\Http\Server->bootstrap()

Steps To Reproduce:

  1.  composer create-project --prefer-dist cakephp/app:4.* example
    
  2.  composer require jgrossi/corcel
    

What I tried

Ideas from https://laracasts.com/discuss/channels/testing/class-phpoptionoption-not-found-when-running-phpunit:

  • composer clear-cache - no effect
  • composer install - no effect
  • composer require 'phpoption/phpoption' - the error changes to:

    PHP message: PHP Fatal error: Uncaught Error: Class "Dotenv\Repository\RepositoryBuilder" not found in /var/www/example/vendor/illuminate/support/Env.php:55
    Stack trace:
    0 /var/www/example/vendor/illuminate/support/Env.php(76): Illuminate\Support\Env::getRepository()
    1 /var/www/example/vendor/illuminate/support/helpers.php(137): Illuminate\Support\Env::get()
    2 /var/www/example/config/app.php(19): env()
    3 /var/www/example/vendor/cakephp/cakephp/src/Core/Configure/Engine/PhpConfig.php(89): include('...')
    4 /var/www/example/vendor/cakephp/cakephp/src/Core/Configure.php(341): Cake\Core\Configure\Engine\PhpConfig->read()
    5 /var/www/example/config/bootstrap.php(81): Cake\Core\Configure::load()
    6 /var/www/example/vendor/cakephp/cakephp/src/Http/BaseApplication.php(173): require_once('...')
    7 /var/www/example/src/Application.php(47): Cake\Http\BaseApplication->bootstrap()
    8 /var/www/example/vendor/cakephp/cakephp/src/Http/Server.php(109): App\Application->bootstrap()

One would think the dependencies should have been loaded automatically?

It appears that you are encountering class not found errors when trying to use the "jgrossi/corcel" package in a fresh install of CakePHP. The error messages indicate that certain classes like "PhpOption\Option" and "Dotenv\Repository\RepositoryBuilder" are not being found.

Based on your description and the steps you've mentioned, it seems that the dependencies required by the "jgrossi/corcel" package are not being automatically loaded by Composer.

To resolve this issue, you can try the following steps:

  1. Clear the Composer cache by running the command: composer clear-cache.

  2. Run composer install to ensure that all the required dependencies are installed properly.

  3. Since you mentioned that the error changes when you require "phpoption/phpoption", it seems that package might be a missing dependency. Try running composer require phpoption/phpoption to install it.

If the above steps don't resolve the issue, it's possible that there might be a compatibility issue between the "jgrossi/corcel" package and the CakePHP version or other dependencies. In such cases, it's worth checking the documentation or support channels for the "jgrossi/corcel" package to see if there are any known issues or specific requirements.

Remember to ensure that you are using compatible versions of packages and that your CakePHP installation meets the requirements specified by the "jgrossi/corcel" package.

commented

@josedarci was that a ChatGPT 3 or GPT 4 response? Just curious