大家好,我正在本地的Windows计算机上运行Symfony 3应用程序。它与XAMPP服务器一起提供。当我访问本地URL时,该应用程序运行良好。问题是我似乎无法在开发环境中运行它。
Symfony应用程序的文件夹结构与我习惯的不同。 app_dev.php位于Intranet文件夹中。
这是Intranet文件夹
我当前的apache配置文件如下:
<VirtualHost *:443>
ServerName quebecenreseau.ca
ServerAlias www.quebecenreseau.ca
SSLEngine on
SSLCertificateFile "crt/quebecenreseau.ca/server.crt"
SSLCertificateKeyFile "crt/quebecenreseau.ca/server.key"
DocumentRoot C:\xampp\htdocs\quebecenreseau
<Directory C:\xampp\htdocs\quebecenreseau>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
ErrorLog C:\xampp\apache\logs\project_error.log
CustomLog C:\xampp\apache\logs\project_access.log combined
</VirtualHost>
我不确定如何配置VirtualHost块,以使开发环境在根目录以及用作网站管理员的Intranet目录上都能正常工作。
如果我这样更改DocumentRoot行:
DocumentRoot C:\xampp\htdocs\quebecenreseau\intranet\app_dev.php
我的应用CSS文件未加载,并且我的Intranet在根级别提供。如何配置本地环境以加载app_dev.php?另外,我的产品环境在centos服务器上,所以我真的不会把产品环境弄得一团糟。
如果您在根目录下徘徊index.php文件中的内容,则为:
<?php
/**
* Start session
*/
session_start();
/**
* Load configuration and router
*/
require 'classes/Router.php';
require 'classes/Database.php';
require 'classes/Main.php';
/**
* Load helpers
*/
require 'helpers/phpmailer/class.phpmailer.php';
require 'helpers/GUMP.php';
require 'helpers/MailChimp.php';
/**
* Load models
*/
require 'models/Article.php';
require 'models/Formation.php';
require 'models/SAE.php';
/**
* Load routes
*/
require 'router.php';
/**
* Match requests
*/
$match = $router->match();
if( $match && is_callable( $match['target'] ) ) {
// call function related to matched route
call_user_func_array( $match['target'], $match['params'] );
} else {
// no route was matched
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}
答案 0 :(得分:2)
尝试将C:\xampp\htdocs\quebecenreseau
更改为C:\xampp\htdocs\quebecenreseau\intranet\web
。如果我没记错的话,文档根目录必须指向app.php和app_dev.php所在的文件夹。
更新:
好的。现在更清楚了。您不在产品中运行纯Symfony项目。有人从Symfony那里学了一些基本的类,并用来路由请求和处理数据库连接。
现在您实际上有两个项目。主文件夹中的纯PHP项目,内网文件夹中的Symfony项目。
所以让我们开始吧。首先,您必须知道,要使Symfony项目作为主应用程序正常运行,根文件夹必须是“ web”文件夹。
所以:
根据我从结构中看到的内容,您将需要进行最小的更改以使其起作用。