2013-04-10 4 views
4

나는 Silex에서 예제를 시도하고 별도의 디렉토리와 클래스에 내 컨트롤러를 넣어.Silex PHP 5.3.2 관련 문제?

아니요 컨트롤러 메서드를 사용하면 RequestApplication 개체가 기본적으로 전달됩니다. 이 5.3.14 있지만 기본 우분투 5.3.2있는 내 dev 컴퓨터에서 작동합니다. 그것은 줘 :

가 여기 내 부트 스트랩 PHP의

PHP Catchable fatal error: Argument 1 passed to Sv\Controller\Index::index() must be an instance of Symfony\Component\HttpFoundation\Request, none given, called in /site/include/app/bootstrap.php on line 23 and defined in /site/include/app/Sv/Controller/Index.php on line 46

:

<?php 

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

use Sv\Repository\PostRepository; 
use Sv\Controller; 

$app = new Silex\Application(); 

// define global service for db access 
$app['posts.repository'] = $app->share(function() { 
    return new Sv\Repository\PostRepository; 
}); 

// register controller as a service 
$app->register(new Silex\Provider\ServiceControllerServiceProvider()); 
$app['default.controller'] = $app->share(function() use ($app) { 
    return new Controller\Index(); 
}); 
$app['service.controller'] = $app->share(function() use ($app) { 
    return new Controller\Service($app['posts.repository']); 
}); 

// define routes 
$app->get('/', 'default.controller:index'); 
$app->get('/next', 'default.controller:next'); 

$service = $app['controllers_factory']; 
$service->get('/', "service.controller:indexJsonAction"); 
// mount routes 
$app->mount('/service', $service); 

// definitions 
$app->run(); 

여기 컨트롤러 코드입니다 :

namespace Sv\Controller; 

use Silex\Application; 
use Symfony\Component\HttpFoundation\Request; 

class Index 
{ 
    public function index(Request $request, Application $app) 
    { 
     return 'Route /index reached'; 
    } 

    public function next(Request $request, Application $app) 
    { 
     return 'Route /next reached'; 
    } 
} 

왜이 작동하지 않는 이유는 무엇입니까?

나는 이것이 당신이 their composer.json에서 볼 수

+1

답은 silex composer.json, 요구 사항 섹션에 있습니다 : ""php ":"> = 5.3.3 " –

+3

37 개월 된 PHP 버전을 실행 중입니다! :) 2010 년 3 월 출시 .. – Evert

+0

@Evert 우분투 10.4를 직접 컴파일하지 않고 최신 버전으로 업데이트 해보세요! 그리고 서버에서 실행되는 t 응용 프로그램에 대해 생각 해보세요. 매우 똑똑합니다! – spankmaster79

답변

6

렉스는 PHP 5.3.3을 필요로 ... PHP 5.3.2에서 ZF2를 사용에서 저를 방지 같은 문제가되지 바랍니다 :

"require": { 
    "php": ">=5.3.3", 
    ... 

그리고 그것은 또한 README file에 명시된 :이 Symfony2 더 이상 PHP 5.3.2을 지원하고있다 때문이다

Silex works with PHP 5.3.3 or later.

.

+0

나는 당신이 5.3.2를 의미한다고 가정한다. – Maerlyn

+0

@Maerlyn 네, 고쳤습니다. 고맙습니다! –

+0

젠장 ... 작곡가를 들여다 보지 않았습니다. – spankmaster79