在本地安装与共享主机目录相同的LARAVEL 5(部署L5共享主机解决方案) [英] Install LARAVEL 5 Locally Same as Share Hosting Directory (Deploy L5 Share Hosting Solution)
问题描述
我正在尝试寻找与共享托管目录相同的组织Laravel应用程序的方法.
I am trying to find the way to organise my Laravel Application same as share hosting directory.
"服务器"文件夹中的示例
1.安装新的laravel应用程序
1.Install fresh laravel application
composer create-project laravel/laravel main-app --prefer-dist
2.将公共"目录上移到main-app文件夹旁边.重命名为public_html
2.Move "Public" directory up and next to main-app folder.Rename to public_html
3.inside public_html文件夹中还创建了一个新的"app"文件夹,以将所有文件保留在index.php之内
3.Inside public_html folder also create new "app" folder to keep all the files like inside index.php
摘要
server
│
└───main-app
│ │ app
│ │ bootstrap
│ │ ......
│
└───public_html
│ app
│ │─── index.php
│
server
│
└───main-app
│ │ app
│ │ bootstrap
│ │ ......
│
└───public_html
│ app
│ │─── index.php
│
这是我需要做的,但是我无法完成这项工作! 每次我尝试经营工匠时,我都会得到
This is what I need to do.But I couldn't make this work! Each time I try to run artisan I got
chdir()没有这样的文件或目录(错误号2)
chdir() no such file or directory (errno 2)
使用Laravel 4,我能够编辑path.php,仅此而已.但是L5似乎又退了一步!
With Laravel 4 I was able to edit path.php and thats it.But L5 looks like one step back!
我已经尝试扩展Application.php类,但不幸的是没有用!
I already tried to extend Application.php class but unfortunately didn't work!
推荐答案
这是解决方案!
1.在应用文件夹中创建MyApp.php类以扩展Applicaton.php类
<?php
namespace App;
class MyApp extends \Illuminate\Foundation\Application
{
public function publicPath()
{
return $this->basePath.DIRECTORY_SEPARATOR.'/../public_html/app';
}
}
2.内部bootsrap/app内部使用自己的课程
确保注释掉旧的! ,您不再需要
Make sure comment out old one! , you don't need anymore
// $app = new Illuminate\Foundation\Application(
// realpath(__DIR__.'/../')
// );
$app = new App\MyApp(
realpath(__DIR__.'/../')
);
3.在server.php内进行更改以定位到index.php
if ($uri !== '/' && file_exists(__DIR__.'/../public_html/app'.$uri)) {
return false;
}
require_once __DIR__.'/../public_html/app/index.php';
4.在index.php内进行更改
require __DIR__.'/../../main-app/bootstrap/autoload.php';
和
$app = require_once __DIR__.'/../../main-app/bootstrap/app.php';
完成
现在,工匠和Index.php的工作与共享托管相同!
Now artisan working and Index.php live same as share hosting!
server
│
└───main-app
│ │ app
│ │ bootstrap
│ │ ......
│
└───public_html
│ app
│ │─── index.php
│
server
│
└───main-app
│ │ app
│ │ bootstrap
│ │ ......
│
└───public_html
│ app
│ │─── index.php
│
这篇关于在本地安装与共享主机目录相同的LARAVEL 5(部署L5共享主机解决方案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!