I'm developing a web service using Slim Framework 2, it's the first time I use php. I'm having an issue with the Slim object:
There's my code:
require 'db.php';
require 'vendor/slim/slim/Slim/Slim.php';
echo 'require ok';
$app = new vendor/slim/slim/Slim();
echo '$app ok';
The 'require' lines are ok. But he $app line doesn't work I use the same path to the Slim.php file and also I've tryed to use this path:
$app = /slim/Slim();
The first echo is executing but the second one is not working. My ws.php file is on the same directori as the vendor folder:
vendor/slim/slim/Slim/
├── Environment.php
├── Exception
│ ├── Pass.php
│ └── Stop.php
├── Helper
│ └── Set.php
├── Http
│ ├── Cookies.php
│ ├── Headers.php
│ ├── Request.php
│ ├── Response.php
│ └── Util.php
├── Log.php
├── LogWriter.php
├── Middleware
│ ├── ContentTypes.php
│ ├── Flash.php
│ ├── MethodOverride.php
│ ├── PrettyExceptions.php
│ └── SessionCookie.php
├── Middleware.php
├── Route.php
├── Router.php
├── Slim.php
└── View.php
Is $app = new vendor/slim/slim/Slim();
correct? I'm lost about this topic.
Solved using Frank Martin solution:
require 'vendor/autoload.php';
$app = new \Slim\App;
Instead:
require 'vendor/slim/slim/Slim/Slim.php';
$app = new vendor/slim/slim/Slim();
Regards