doubeng9407 2012-12-19 08:21
浏览 45

嵌套Silex应用程序

How would one go about nesting Silex applications?

I'm setting up a project demo for my client such that they will be able to visit mydomain.net/project/demo and see their site live.

My directory structure:

www
  mydomain.net
    projects
        client_project
          app
            web
              index.php    <-client project front controller
        another_client_project
          app
            web
              index.php    <-another client project front controller
    src
    vendor
    web   <-apache docroot
      index.php    <-front controller for my site

So my thinking is that I should be able to create a route on my front controller that just refers the user agent to one of the nested, client project specific front controllers. The url might look like: http://mydomain.net/projects/client_project/

Silex has a convenient facility for making what they call a sub request, like so:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

$app->get('/', function () use ($app) {
    // redirect to /hello
    $subRequest = Request::create('/hello', 'GET');

    return $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
});

So... this is where I run aground. Can I just fashion a request that refers to a given nested front controller? Will this require some mod_rewrite action?

  • 写回答

1条回答 默认 最新

  • douzhuican0041 2013-10-10 00:30
    关注

    Since you probably used mod_rewrite (or its analog in nginx, lighttpd, etc) to feed everything to index.php for routing, you can also use that to build these nested applications. Just build a rewrite pattern for each client project and send it to the client-specific index.php

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法