I am trying to create a shopping cart for my website, I am following the tutorial below: https://www.youtube.com/watch?v=tRh467FX12U&list=PLfdtiltiRHWH9JN1NBpJRFUhN96KBfPmd&index=2
In the tutorial, he uses 3 different imports from GitHub and this is how installed them in the terminal using composer:
rosscurrie = Name of ~user
@Ross-Air = Name of Macbook
MobileMastersNew = Name of the folder that holds all website files
composer = is installed globally
require <...> = the imports from GitHub
I have limited experience with Laravel but not completely unfamiliar. When I try to load the index.php page it gets this error:
Fatal error: Uncaught Error: Class 'DI\Bridge\Slim\App' not found in /Users/rosscurrie/Sites/MobileMastersNew/app/App.php:8 Stack trace: #0 /Users/rosscurrie/Sites/MobileMastersNew/vendor/composer/ClassLoader.php(444): include() #1 /Users/rosscurrie/Sites/MobileMastersNew/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/Users/rosscurr...') #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Cart\\App') #3 /Users/rosscurrie/Sites/MobileMastersNew/bootstrap/app.php(9): spl_autoload_call('Cart\\App') #4 /Users/rosscurrie/Sites/MobileMastersNew/public/index.php(3): require('/Users/rosscurr...') #5 {main} thrown in /Users/rosscurrie/Sites/MobileMastersNew/app/App.php on line 8
My folder directory is as follows:
My ../MobileMasters/app/App.php is:
<?php
namespace Cart;
use DI\ContainerBuilder;
use DI\Bridge\Slim\App as DIBridge;
class App extends DIBridge
{
protected function configureContainer(ContainerBuilder $builder)
{
$builder->addDefinitions([
'settings.displayErrorDetails' => true,
]);
//
}
}
My ../MobileMasters/bootstrap/app.php is:
<?php
session_start();
use Cart\App;
require __DIR__ . '/../vendor/autoload.php';
$app = new App;
My ../MobileMasters/public/.htaccess file is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
My ../MobileMasters/public/index.php is:
<?php
require __DIR__ . '/../bootstrap/app.php';
$app->run();
My ../MobileMasters/vendor/autoload.php is:
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit2e9ebb4be0f95ed0dbfb26486b8ba4b7::getLoader();
Lastly, my ../MobileMasters/composer.json is:
{
"require": {
"slim/slim": "^4.0",
"slim/twig-view": "^3.0",
"php-di/slim-bridge": "^3.0",
"illuminate/database": "^7.2"
},
"autoload": {
"psr-4": {
"Cart\\": "app"
}
}
}
You should use use statement after autoloading:
<?php
namespace Cart;
use DI\ContainerBuilder;
use DI\Bridge\Slim\App as DIBridge;
class App extends DIBridge
{
protected function configureContainer(ContainerBuilder $builder)
{
$builder->addDefinitions([
'settings.displayErrorDetails' => true,
]);
//
}
}
And change this file also:
session_start();
require __DIR__ . '/../vendor/autoload.php';
use Cart\App;
$app = new App;