Error in new install of Slim

Hi

Recently installed slim framework on my webserver. But when i run the exampe code i get a PHP error that I don’t really know how to fix.

[Sun May 22 19:11:45 2016] [error] [client 83.251.151.170] PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/site/vendor/slim/slim/Slim/Container.php on line 151

followed the tutorial on http://www.slimframework.com/docs/tutorial/first-app.html

The code that runs in index.php is:

<?php

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});
$app->run();

The specific line that the error message points to is:

    return $trace['class'] === PimpleContainer::class && $trace['function'] === 'offsetGet';

Perhaps it is the ::class constant that is not working for you. What version of PHP are you using? It should be PHP 5.5 or better.

Hi

yest i figured there was a problem what failed on that row. Not the row itself.

I’m using
PHP 5.6.21-9+donate.sury.org~precise+1 (cli)
Copyright © 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright © 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright © 1999-2016, by Zend Technologies

On a ubuntu 12.04 LTS.
Do you have any idea on how to solve this? I can’t re install the server or build a new one since there are some other sites running same server.

Thanks

The version is fine. Do you get the same version number when you put

<?php phpinfo();

on a page and open the page in your browser?

Hi
Yes i do.

PHP Version 5.4.45-3+donate.sury.org~precise+3

also did a clean re-install and got the same problem for the 10th time to :slight_smile:

Could this be the problem?

Server API Apache 2.0 Handler

Your second php version is 5.4, which is not supported

I see, need to figure out how to get apache2 to use the later PHP version. Thanks!