将现有的 Cakephp 3 项目设置到本地 XAMPP
Setting up existing Cakephp 3 project to local XAMPP
所以我正在为我的本地 XAMPP 设置一个名为 CakeApp 的现有 Cakephp 3 项目。我将 CakeApp 文件夹放在 C:\xampp\htdocs\
中,我可以在 http://localhost/CakeApp
中访问它的主页。它会自动将我重定向到 http://localhost/CakeApp/users/login
,这是假定的主页。我正在尝试访问 Cakephp 的主要 src\Pages\home.ctp
,但首先要检查项目是否已在我的本地 XAMPP 中成功设置。所以在config\routes.php
中,我改变了:
Router::scope('/', function ($routes) {
$routes->connect('/',
['controller' => 'Pages', 'action' => 'index']
);
$routes->fallbacks('DashedRoute'); });
至
Router::scope('/', function ($routes) {
$routes->connect('/',
['controller' => 'Pages', 'action' => 'home']
);
$routes->fallbacks('DashedRoute'); });
现在 http://localhost/CakeApp
给我一个 Error: The requested address '/CakeApp/' was not found on this server.
所以在src\Pages\home.ctp
中,我注释掉了:
if (!Configure::read('debug')):
throw new NotFoundException();
endif;
虽然它仍然给我同样的 Error: The requested address '/CakeApp/' was not found on this server.
。所以在src\Controller\PagesController.php
,我发现home
没有任何动作。所以我创建了:
public function home() {
}
现在,转到 http://localhost/CakeApp
会自动将我重定向到 http://localhost/CakeApp/users/login
。我正在尝试访问 home.ctp
,它为我提供了有关 Cakephp 项目设置的信息。
任何帮助将不胜感激。非常感谢。
你能把routes.php中的所有代码都注释掉然后替换成这段代码吗
<?php
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::defaultRouteClass('Route');
Router::scope('/', function ($routes) {
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
$routes->fallbacks('InflectedRoute');
});
Router::extensions('json', 'xml');
/**
* Load all plugin routes. See the Plugin documentation on
* how to customize the loading of plugin routes.
*/
Plugin::routes();
?>
所以我正在为我的本地 XAMPP 设置一个名为 CakeApp 的现有 Cakephp 3 项目。我将 CakeApp 文件夹放在 C:\xampp\htdocs\
中,我可以在 http://localhost/CakeApp
中访问它的主页。它会自动将我重定向到 http://localhost/CakeApp/users/login
,这是假定的主页。我正在尝试访问 Cakephp 的主要 src\Pages\home.ctp
,但首先要检查项目是否已在我的本地 XAMPP 中成功设置。所以在config\routes.php
中,我改变了:
Router::scope('/', function ($routes) {
$routes->connect('/',
['controller' => 'Pages', 'action' => 'index']
);
$routes->fallbacks('DashedRoute'); });
至
Router::scope('/', function ($routes) {
$routes->connect('/',
['controller' => 'Pages', 'action' => 'home']
);
$routes->fallbacks('DashedRoute'); });
现在 http://localhost/CakeApp
给我一个 Error: The requested address '/CakeApp/' was not found on this server.
所以在src\Pages\home.ctp
中,我注释掉了:
if (!Configure::read('debug')):
throw new NotFoundException();
endif;
虽然它仍然给我同样的 Error: The requested address '/CakeApp/' was not found on this server.
。所以在src\Controller\PagesController.php
,我发现home
没有任何动作。所以我创建了:
public function home() {
}
现在,转到 http://localhost/CakeApp
会自动将我重定向到 http://localhost/CakeApp/users/login
。我正在尝试访问 home.ctp
,它为我提供了有关 Cakephp 项目设置的信息。
任何帮助将不胜感激。非常感谢。
你能把routes.php中的所有代码都注释掉然后替换成这段代码吗
<?php
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::defaultRouteClass('Route');
Router::scope('/', function ($routes) {
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
$routes->fallbacks('InflectedRoute');
});
Router::extensions('json', 'xml');
/**
* Load all plugin routes. See the Plugin documentation on
* how to customize the loading of plugin routes.
*/
Plugin::routes();
?>