Install LARAVEL 5 Locally Same as Share Hosting Directory (Deploy L5 Share Hosting Solution)

ぃ、小莉子 提交于 2019-12-04 20:38:17

Here is Solution !

1.Create MyApp.php class inside app folder to extend Applicaton.php class

<?php 
namespace App;

class MyApp  extends \Illuminate\Foundation\Application
{
    public function publicPath()
    {
        return $this->basePath.DIRECTORY_SEPARATOR.'/../public_html/app';
    }
}

2.Inside bootsrap/app use own class

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.Make changes inside server.php to target index.php

if ($uri !== '/' && file_exists(__DIR__.'/../public_html/app'.$uri)) {
      return false;
}


require_once __DIR__.'/../public_html/app/index.php';

4.Make changes inside index.php

require __DIR__.'/../../main-app/bootstrap/autoload.php';

and

$app = require_once __DIR__.'/../../main-app/bootstrap/app.php';

DONE

Now artisan working and Index.php live same as share hosting!

server │
└───main-app │ │ app │ │ bootstrap │ │ ...... │ └───public_html │ app │ │─── index.php │

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!