13

I moved my website from local to a hosting, and something happened to me. I include this config file into my index.php (it's the first thing I do):

<?php
require_once __DIR__.'/../../vendor/autoload.php';

// some other stuff

$app = new Silex\Application();
$app['debug'] = true;

$defaultLocale = 'en';

$app->register(new Silex\Provider\TwigServiceProvider(), array(
    'twig.path' => array(
                            __DIR__.'/../views', 
                            __DIR__.'/../views/backend', 
                            __DIR__.'/../views/layouts',
                            __DIR__.'/../views/components',
                            __DIR__.'/../views/backend/components', 
                        ),
));
$app->register(new Nicl\Silex\MarkdownServiceProvider());

But the website complains this way:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /public_html/_inc/config.php on line 7

Parse error: syntax error, unexpected T_STRING in /public_html/_inc/config.php on line 7

Basically, line 7 is $app = new Silex\Application();. I'm using Silex and the server is running PHP 5.2. The vendor folder (which contains all the framework and third parties stuff) is in root (/)

I was wondering it had some problems with autoload, but I don't find what could exactly be or how to test it. Do you find anything strange? Thanks in advance.

hakre
  • 193,403
  • 52
  • 435
  • 836
Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
  • Maybe I had to try harder, but I already searched for this. However _almost_ everybody was showing unrelated solutions. – Sergi Juanola Oct 29 '12 at 16:28
  • Yes, I didn't say it's super-easy. Your question is fine btw. Also Florent is straight to the point. We should keep it for further reference. – hakre Oct 29 '12 at 16:29
  • great to hear that. I added the [namespaces] tag, for the sake of the answer. – Sergi Juanola Oct 29 '12 at 16:30
  • I just added the php-errors tag as well. We also try to improve the "error message" - to -> "solution" situation with this reference: http://stackoverflow.com/q/12769982/367456 - probably this is of help from time to time. – hakre Oct 29 '12 at 16:34

1 Answers1

20

According to the official documentation, Silex requires PHP 5.3 to provide namespace support.
Try to migrate your server to PHP 5.3 in order to get rid of this error.

Silex is a PHP microframework for PHP 5.3.

Florent
  • 12,310
  • 10
  • 49
  • 58