更改Laravel 5.1的公用文件夹

时间:2015-09-27 09:43:19

标签: laravel laravel-5 laravel-5.1

我正在寻找一种方法来改变laravel 5.1中公共文件夹的名称,因为我的主机只允许我使用htdocs文件夹。

2 个答案:

答案 0 :(得分:2)

我按照这里提到的步骤进行了操作:https://laracasts.com/discuss/channels/general-discussion/where-do-you-set-public-directory-laravel-5

  1. bootstrap/app.php中添加

    $app->bind('path.public', function() {
          return base_path('htdocs');
    });
    
  2. 然后,在/server.php中,将public的两次出现更改为htdocs(或者您要使用的任何内容)。

  3. 我真诚地希望在任何情况下都能发挥作用。

    编辑2016-10-18:

    我最近不得不这样做,但这次我的主持人允许我删除“htdocs”文件夹(我有一个ssh访问权限):

    • 我在根据“htdocs”文件夹
    • 下面的根文件夹中安装了Laravel
    • 我删除了“htdocs”文件夹
    • 我创建了一个符号链接,将“htdocs”映射到“public”:ln -s public htdocs

答案 1 :(得分:0)

这就是我做到的..更新和其他事情到目前为止都很有效..

在root上创建一个新文件夹..并移动其中的所有文件夹(例如,调用它" myfolder")然后将公共文件夹中的文件移动到root ..所以它应该看起来像。

Html.ActionLink

使用文本编辑器打开server.php并替换为此代码..

a

然后在index.php上

/myfolder/
/index.php
/server.php
/.htaccess
/favicon

然后转到" /myfolder/bootstrap/autoload.php" ..

<?php

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

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/'.$uri)) {
    return false;
}

require_once __DIR__.'/index.php';

和同一文件夹中的app.php

<?php

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

/*
|--------------------------------------------------------------------------
| 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 nice to relax.
|
*/

require __DIR__.'/myfolder/bootstrap/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__.'/myfolder/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);

在开发和生产环境方面适合我。