2016-05-25 20 views
1

Ich hatte den folgenden Code, der auf PHP 5.6 und Apache 2.2 funktionierte. Ich denke, ich habe meinen Apache einfach auf 2.4 aufgerüstet und es scheint aufgehört zu haben zu arbeiten.404 Not Found beim Routing mit Silex

api 
-app 
    -job 
    -jobController.php 
    -jobFacade.php 
    -jobFacadeProvider.php 
    -src 
    -BatchAutoscalingApplication.php 
    -routes.php 
    -app.php 
    -index.php 

routes.php

<?php 
    require_once __DIR__ . "/../job/JobController.php"; 
    $app->mount("/job", new JobController()); 
?> 

jobCOntroller.php

<?php 
    require_once __DIR__ ."/JobFacade.php"; 

    class JobController implements ControllerProviderInterface 
    { 
     public function connect(Application $app) 
     { 

      $controllers = $app['controllers_factory']; 
      error_log("isnide cntroller",false); 
      $controllers->get('/isAcceptable', function (Request $request) use ($app) { 

       $id_contents = $request->query->get('id_contents'); 
       $result = $app['job']->isAcceptable($id_contents, $id_host, $id_vhost, $private_ip); 
       return new JsonResponse($result); 
      }); 

      return $controllers; 
     } 

     public function boot(Application $app) 
     { 
      // TODO: Implement boot() method. 
     } 
    } 
?> 

jobFacade.php

class JobFacade 
    { 
     public function isAcceptable($id_contents) 
     { 
      return "something" 
     } 
    } 

JobFacadeProvider.php

class JobFacadeProvider implements ServiceProviderInterface 
    { 
     public function register(Application $app) { 
      $app['job'] = $app->share(function() use ($app) { 
       return new JobFacade(); 
      }); 
     } 
     public function boot(Application $app) {} 
} 

index.php

$app = require_once __DIR__ . '/app/app.php'; 
    $app->after($app["cors"]); 

    $app->run(); 

?> 

BatchAutoscalingApplication.php

class BatchAutoScalingApplication extends Application 
    { 
     public function __construct(array $values = array()) 
     { 
      parent::__construct($values); 
      $this->register(new CorsServiceProvider(), array(
       "cors.allowOrigin" => "*", 
      )); 

      $this->register(new JobFacadeProvider()); 

     } 

    } 

app.php

$app = new BatchAutoScalingApplication(); 

    require_once __DIR__ . '/src/routes.php'; 

    return $app; 

?> 

Wenn ich die URL getroffen http://<host>/job/isAcceptable?id_contents=34, es gibt mir die folgenden Fehler

404 Not Found The requested URL /job/isAcceptable was not found on this server

PS: Die DocumentRoot zum api Verzeichnis gerichtet ist.

Antwort

1

Es war ein dummer Fehler. Ich habe einfach AllowOverride All in meinem httpd.conf hinzugefügt und es scheint jetzt in Ordnung zu arbeiten.

Verwandte Themen