在laravel中将公用文件夹重命名为public_html



我在项目中使用Laravel和Vuejs。在我的项目中,我将公用文件夹的名称更改为public_html。当我运行";npm跑步手表;命令,公用文件夹再次创建,这对我来说是个问题。

在AppServiceProvider 中

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind('path.public',function (){
return base_path().'/public_html';
});
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}

在我的server.php代码中:

<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package  Laravel
* @author   Taylor Otwell <taylor@laravel.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__ . '/public_html' . $uri)) {
return false;
}
require_once __DIR__ . '/public_html/index.php';

和webpack.mix.js

const mix = require('laravel-mix');
/*
|-------------------------------------------------------------
| Mix Asset Management
|------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build 
steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public_html/js')
.sass('resources/sass/app.scss', 'public_html/css');

有人知道如何解决这个问题,这样就不会重新创建公用文件夹了吗?

您可以通过在webpack.mix.js 中调用mix.setPublicPath("your-public-path")来实现这一点

最新更新