0

Hi Ive been trying to create a shopping cart via php. To do this I have been using the Slim 3 Framework, however I've run into some error and I can't seem to understand what the issue is. Any help is appreciated, thanks!

Error Log from Slim

routes.php

The error seems to be with the syntax of the get function below.

<?php 


$app->get('/', ['Cart\Controllers\HomeController', 'index'])->setName('home');


?>

Container.php

use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Interop\Container\ContainerInterface;
use function DI\get;

return [

    'router' => get(Slim\Router::class),

    Twig::class => function (ContainerInterface $c)
    {
        $twig = new Twig(__DIR__ . '/../resources/views', [

            'catche' => false

            ]);

            $twig->addExtension(new TwigExtension(

                $c->get('router'),
                $c->get('request')->getUri()


            ));


            return $twig;
        }

];

?>
Advait Kulkarni
  • 139
  • 2
  • 12

1 Answers1

-1

In this line

$app->get('/', ['Cart\Controllers\HomeController', 'index'])->setName('home');

you wrote

['Cart\Controllers\HomeController', 'index']

however in the error log it says

['Cart\\Controllers\\HomeController', 'index']

Notice the double backslashes. Can you check why this is happening?

Julius
  • 64
  • 5
  • 2
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you [earn](http://meta.stackoverflow.com/q/146472/169503) sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). If you have a related but different question, [ask a new question](http://stackoverflow.com/questions/ask) referencing this one if it will help provide context. – Bhargav Rao Oct 27 '16 at 13:26