Hi everyone, I have a cart project which works as it should when run locally, but when I deploy it to my digital ocean server through forge I get this error... Fatal error: Uncaught Error: Class 'Store\Models\product' not found in /home/forge/website.com/app/container.php:42.
As far as I can tell I am running the same version of PHP. Anyone know what might be causing this?
as @Francesco Zaffaroni says i fell into this at an early stage but where it says Class 'Store\Models\product'check that the filename and classname product is in lowercase otherwise if your server is case sensitive this is more likely the issue.
SO ensure that all mentions of classes etc are the same as the filename and classname regarding capitalisation etc
Ha, that was the problem. I though I had checked that but obviously overlooked capitalisation.
So that is now fixed, but I now get a slim error:
Message: Cannot call index on Store\Controllers\HomeController because it is not a class nor a valid container entry
I also get this in my forge failed deployment log:
Fatal error: Uncaught Error: Call to a member function make() on integer in /home/forge/website.com/artisan:31
Stack trace:
#0 {main}
thrown in /home/forge/website.com/artisan on line 31
It looks like $app in the artisan file is not initialized correctly. are you sure composer install has been run on the server?
About the controller I can't help you. No idea.
use Slim\Views\Twig;
use Store\Models\Product;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class HomeController{
public function index(Request $request, Response $response, Twig $view, Product $product){
$products =$product->get();
return $view->render($response, 'home.twig', [
'products' => $products
]);
}
}