iT邦幫忙

1

Laravel 新手請益 輸入localhost卻出現public資料夾

小弟是Laravel新手,目前正在練習套版,使用的工具是XAMPP
原本一切都好好的,打開瀏覽器輸入localhost也都會出現套版的畫面
但不知道是碰到什麼,再次輸入localhost時,卻導入到我的/public資料夾下的檔案列表

如圖:
https://ithelp.ithome.com.tw/upload/images/20180922/20111881oJ6ibQqWsY.png

請問是跟.htaccess這檔案有關嗎?因為在出現這問題之前,我有點開這檔案看一下,但應該是沒有更改到程式碼才對

求大大們幫忙

0
黃彥儒
iT邦研究生 2 級 ‧ 2018-09-22 20:01:09

有關,不過應該是沒有index的緣故

0
shijung
iT邦新手 5 級 ‧ 2018-09-23 05:18:14

https://ithelp.ithome.com.tw/upload/images/20180923/201106157xBqEhXCT4.png
Laravel 本當就是倒到public沒錯 你少了一個index.php
如果你是5.6版本可以用這個

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

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

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

我建議你再建一個Laravel專案 打開public 直接copy index.php比較好

0
code
iT邦新手 5 級 ‧ 2018-09-24 09:05:38

你是不是一開始有用artisan serve??
一般XAMPP首頁的位址都在 你的IP/專案名稱/public
這個裡面唷~

我要發表回答

立即登入回答