Thi*_*ghe 5 php shared-hosting laravel vue.js
I built a single page web app with vue js as the front-end library and laravel as the back-end framework. Its now time to host it on a shared hosting service and have not found any clear steps on how to do this successfully with the Api Routes of the loading as programmed.
I copied content of laravel public folder and build files of vue js to the public_html folder in shared hosting. Then it's loading the frontend without data from the backend. Should I have to use two separate ip addresses for backend and frontend or is it possible to use same shared hosting storage for deploy my Vue js frontend and laravel backend(api routes).
//index.php of laravel
<?php
require __DIR__.'/../jewelpack_app/vendor/autoload.php';
$app = require_once __DIR__.'/../jewelpack_app/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
?>
Run Code Online (Sandbox Code Playgroud)
//web.php of laravel routes
<?php
Route::get('/{any}', function(){
return view('index');//pointing to the index file of the frontend
})->where('any', '.*');
?>
Run Code Online (Sandbox Code Playgroud)
小智 0
首先,你应该将 laravel 项目分成 2 个文件夹
\n\n$app = require_once DIR.\xe2\x80\x99/../bootstrap/app.php\xe2\x80\x99;\n
吨$app = require_once DIR.\xe2\x80\x99/../laravel/bootstrap/app.php\xe2\x80\x99;\n
对于 Laravel 5 添加以下内容:
\n\n$app->bind('path.public', function() {\nreturn __DIR__;\n});
希望这能解决您的问题。
\n