在 Symfony2 中重命名应用程序文件夹
Rename an app folder in Symfony2
我一直在寻找如何在 Symfony 2 中重命名应用程序文件夹,但我找不到任何东西。我认为这是可行的,但我不知道该怎么做。
有人能帮帮我吗?
查看您的 composer.json
文件。具体来说:
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
将 symfony-app-dir
更改为您想要的值。您还必须将路径更改为 incenteev-parameters.file
以及可能明确针对 app
目录的任何其他路径。
然后...您需要相应地更改 web/app.php
和 web/app_dev.php
文件中的一些路径。例如:
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../apps/bootstrap.php.cache';
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
/*
$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
*/
require_once __DIR__.'/../apps/AppKernel.php';
//require_once __DIR__.'/../apps/AppCache.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
$loader
和 require_once
路径必须更改。我假设也可能需要清除缓存和作曲家更新。
那么它应该可以正常工作。该文档讨论了 overriding the default file structure 但没有说明 app
目录。然而,我在这里做了一个快速测试,它似乎在这里工作得很好。 YMMV!
希望对您有所帮助:)
我一直在寻找如何在 Symfony 2 中重命名应用程序文件夹,但我找不到任何东西。我认为这是可行的,但我不知道该怎么做。
有人能帮帮我吗?
查看您的 composer.json
文件。具体来说:
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
将 symfony-app-dir
更改为您想要的值。您还必须将路径更改为 incenteev-parameters.file
以及可能明确针对 app
目录的任何其他路径。
然后...您需要相应地更改 web/app.php
和 web/app_dev.php
文件中的一些路径。例如:
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../apps/bootstrap.php.cache';
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
/*
$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
*/
require_once __DIR__.'/../apps/AppKernel.php';
//require_once __DIR__.'/../apps/AppCache.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
$loader
和 require_once
路径必须更改。我假设也可能需要清除缓存和作曲家更新。
那么它应该可以正常工作。该文档讨论了 overriding the default file structure 但没有说明 app
目录。然而,我在这里做了一个快速测试,它似乎在这里工作得很好。 YMMV!
希望对您有所帮助:)