matthiasstraka / php-invest

Self-hosted stock portfolio tracking software using PHP/Symfony. It tracks portfolios across multiple brokers and automatically updates daily stock data. It allows tracking trades of raw stock and EUSIPA derivatives/instruments.
GNU General Public License v3.0
18 stars 7 forks source link

ClassNotFoundError Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle". #36

Open nifunifatralara opened 7 months ago

nifunifatralara commented 7 months ago

I am getting this error and can't figure out how to fix it:

ClassNotFoundError HTTP 500 Internal Server Error Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle". Did you forget a "use" statement for another namespace? Symfony\Component\ErrorHandler\Error\ ClassNotFoundError in vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php (line 136) in [...]vendor/symfony/http-kernel/Kernel.php -> registerBundles (line 346) in [...]vendor/symfony/http-kernel/Kernel.php -> initializeBundles (line 762) in [...]vendor/symfony/http-kernel/Kernel.php -> preBoot (line 185) in [...]vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php -> handle (line 35) in [...]vendor/autoload_runtime.php -> run (line 29) require_once('[...]vendor/autoload_runtime.php') in [...]public/index.php (line 5)

<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
    return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
matthiasstraka commented 7 months ago

How did you install the website? It looks like you are using the doctrine-fixtures-bundle, which is only required for development/testing. Have you tried to install with composer using the --no-dev option? composer install --no-dev I just updated the Dockerfile so it works again. I also updated the readme where I explain how to set an APP_SECRET, which is now required (use a custom secret). I tested the website in a fresh Docker container and I did not encounter a load error there. Personally, I'm running this site in a native Ubuntu 22.04 server, which works fine in both dev and no-dev environments.

nifunifatralara commented 7 months ago

Hi, Thanks for the fast reply! Yes I did install it with the --no-dev option, following the instructions of the README Now I started over again, cloning the repo and following the instructions, and I am getting a 500 error "Uncaught PHP Exception Symfony\Component\Cache\Exception\CacheException: "APCu is not enabled." at ApcuAdapter.php line 31" but according to phpinfo(), APCU is enabled:

php -r "phpinfo();" | grep -i apcu apcu APCu Support => Enabled APCu Debugging => Disabled

Maybe I need to activate the APCu debugging?

Thanks again :)

nifunifatralara commented 7 months ago

Forgot to mention: I had indeed *not created a .env.local file the first time, but I did now, adding an APP_SECRET as instructed

nifunifatralara commented 7 months ago

FYI : I had to add this "ENV COMPOSER_ALLOW_SUPERUSER=1" to the Dockerfile, before "RUN composer install --no-dev", because I was getting an error about permissions when trying to run the docker demo. So now the docker demo works, but the regular install still throws that 500 error about APCu

matthiasstraka commented 7 months ago

I'm not really sure what causes these issues, apparently, they are composer/PHP related. At the moment my time is very limited but I do want to understand what the issue is. On what system (linux, php version, etc.) are you trying to set the site up? Maybe I can reproduce it somehow. Both my production and dev system have been set up for years, maybe an updated component causes these problems, but then - why does it work in a fresh docker install?

mostafazs commented 1 week ago

FYI : I had to add this "ENV COMPOSER_ALLOW_SUPERUSER=1" to the Dockerfile, before "RUN composer install --no-dev", because I was getting an error about permissions when trying to run the docker demo. So now the docker demo works, but the regular install still throws that 500 error about APCu

To install fixtures you need a dev environment .. go to .env.local and change APP_ENV= to dev