【问题标题】:Run a Project on browser from IntelliJ IDE从 IntelliJ IDE 在浏览器上运行项目
【发布时间】:2018-01-15 16:33:14
【问题描述】:

我打开了一个在 IntelliJIDEA IDE 中下载的项目。项目结构如下。我正在尝试运行userAuthenticationController.php 控制器的index() 方法来查看登录页面。

根据本项目的config.php文件,base_url提供如下。

config.php

$config['base_url'] = 'http://localhost:9080/Internship-Management/Sourcecode/Codeigniter/';

我尝试在 Chrome 中运行此地址,但收到以下错误。

userAuthenticationController.php

// Show login page
public function index() {
$this->load->view('login/loginView');
}

routes.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|   example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|   https://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are three reserved routes:
|
|   $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|   $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
|   $route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
|       my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

是否需要更改用于在浏览器中加载控制器的路径?

在这方面的任何建议都将受到高度赞赏。

【问题讨论】:

    标签: php intellij-idea routes localhost base-url


    【解决方案1】:

    不幸的是,在 IDEA/PhpStorm 中打开一个项目是不够的。

    您仍然需要:

    1. 安装 Apache(我认为使用 XAMPP 对你来说是最好的选择)

    2. 将其配置为在端口 9080 上运行(根据您发布的配置文件)

    3. 将项目部署到 Apache Web 根目录(手动,或使用 PhpStorm/IDEA 部署配置)

    【讨论】:

    • 感谢尤金的评论。是的,我确实已经安装了 WAMP,因此 Apache 不是问题,但端口是。我确实起飞了 9080 并以http://localhost/internship-management/sourcecode/codeigniter/index.php/userAuthenticationController/userLoginProcess 的身份运行该程序,它可以工作。谢谢
    猜你喜欢
    • 1970-01-01
    • 2018-12-19
    • 2021-10-19
    • 1970-01-01
    • 2023-04-06
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    相关资源
    最近更新 更多