简体   繁体   English

将现有的Cakephp 3项目设置为本地XAMPP

[英]Setting up existing Cakephp 3 project to local XAMPP

So I'm setting up an existing Cakephp 3 project named CakeApp to my local XAMPP. 所以我要在本地XAMPP上建立一个名为CakeApp的现有Cakephp 3项目。 I put the CakeApp folder inside C:\\\\xampp\\htdocs\\ and I am able to access its main page in http://localhost/CakeApp . 我将CakeApp文件夹放在C:\\\\xampp\\htdocs\\并且能够访问http://localhost/CakeApp It automatically redirects me to http://localhost/CakeApp/users/login which is the supposed main page. 它会自动将我重定向到http://localhost/CakeApp/users/login ,这是假定的主页。 I'm trying to access the Cakephp's main src\\Pages\\home.ctp though to check first if the project was successfully set up in my local XAMPP. 我正在尝试访问Cakephp的主src\\Pages\\home.ctp但首先要检查该项目是否已在本地XAMPP中成功设置。 So in config\\routes.php , I changed: 所以在config\\routes.php ,我更改了:

Router::scope('/', function ($routes) {

$routes->connect('/',
        ['controller' => 'Pages', 'action' => 'index']
    );

$routes->fallbacks('DashedRoute');     });

to

Router::scope('/', function ($routes) {

$routes->connect('/',
        ['controller' => 'Pages', 'action' => 'home']
    );

$routes->fallbacks('DashedRoute');    });

Now http://localhost/CakeApp is giving me an Error: The requested address '/CakeApp/' was not found on this server. 现在http://localhost/CakeApp给我一个Error: The requested address '/CakeApp/' was not found on this server.

So in src\\Pages\\home.ctp , I commented out: 因此,在src\\Pages\\home.ctp ,我注释掉了:

if (!Configure::read('debug')):
    throw new NotFoundException();
endif;

It is still giving me the same Error: The requested address '/CakeApp/' was not found on this server. 它仍然给我同样的Error: The requested address '/CakeApp/' was not found on this server. though. 虽然。 So in src\\Controller\\PagesController.php , I found out that there was no action for home . 因此,在src\\Controller\\PagesController.php ,我发现home没有任何操作。 So I created: 所以我创建了:

public function home() {
}

Now, going to http://localhost/CakeApp automatically redirects me again to http://localhost/CakeApp/users/login . 现在,转到http://localhost/CakeApp自动将我再次重定向到http://localhost/CakeApp/users/login I'm trying to access home.ctp which gives me information about the Cakephp project set up. 我正在尝试访问home.ctp ,它为我提供了有关Cakephp项目设置的信息。 Any help would be greatly appreciated. 任何帮助将不胜感激。 Thank you very much. 非常感谢你。

can you comment all the codes in the routes.php then replace to this code 您可以注释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();
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM