Programming

유효한 캐시 경로를 제공하십시오

procodes 2020. 7. 29. 20:37
반응형

유효한 캐시 경로를 제공하십시오


작동하는 laravel 앱을 복제하고 다른 앱에 사용하도록 이름을 변경했습니다. 공급 업체 폴더를 삭제하고 다음 명령을 다시 실행하십시오.

composer self-update

composer-update

npm install

bower install

브라우저에서 앱을 실행하려고하면 경로와 모든 것을 올바르게 구성했지만 다음과 같은 오류가 발생합니다.

Compiler.php 36 행의 InvalidArgumentException : 유효한 캐시 경로를 입력하십시오.

Filesystem.php 줄 111의 ErrorException : file_put_contents (F : \ www \ example \ app \ storage \ framework / sessions / edf262ee7a2084a923bb967b938f54cb19f6b37d) : 스트림을 열지 못했습니다 : 해당 파일 또는 디렉토리가 없습니다

나는 전에이 문제를 겪어 본 적이 없으며, 원인을 모르거나 해결 방법을 모른다. 온라인으로 해결책을 찾기 위해 검색했지만 지금까지 아무도 찾지 못했다.


다음을 시도하십시오 :

저장 / 프레임 워크 에서 다음 폴더를 만듭니다 .

  • sessions
  • views
  • cache

이제 작동합니다


이 시도:

  1. php artisan cache:clear
  2. php artisan config:clear
  3. php artisan view:clear

따라서 분명히 내 프로젝트를 복제 할 때 스토리지 폴더 내의 프레임 워크 폴더가 새 디렉토리에 복사되지 않아서 내 오류가 발생했습니다.


다음 과 같이 다른 환경에 laravel 앱을 설치하기위한 지침으로 readme.md편집 할 수 있습니다 .

## Create folders

```
#!terminal

cp .env.example .env && mkdir bootstrap/cache storage storage/framework && cd storage/framework && mkdir sessions views cache

```

## Folder permissions

```
#!terminal

sudo chown :www-data app storage bootstrap -R
sudo chmod 775 app storage bootstrap -R

```

## Install dependencies

```
#!terminal

composer install

```

이 오류의 원인은 Illuminate \ View \ Compilers \ Compiler.php에서 추적 할 수 있습니다.

public function __construct(Filesystem $files, $cachePath)
{
    if (! $cachePath) {
        throw new InvalidArgumentException('Please provide a valid cache path.');
    }

    $this->files = $files;
    $this->cachePath = $cachePath;
}

생성자는 Illuminate \ View \ ViewServiceProvider의 BladeCompiler에 의해 호출됩니다.

/**
 * Register the Blade engine implementation.
 *
 * @param  \Illuminate\View\Engines\EngineResolver  $resolver
 * @return void
 */
public function registerBladeEngine($resolver)
{
    // The Compiler engine requires an instance of the CompilerInterface, which in
    // this case will be the Blade compiler, so we'll first create the compiler
    // instance to pass into the engine so it can compile the views properly.
    $this->app->singleton('blade.compiler', function () {
        return new BladeCompiler(
            $this->app['files'], $this->app['config']['view.compiled']
        );
    });

    $resolver->register('blade', function () {
        return new CompilerEngine($this->app['blade.compiler']);
    });
}

따라서 다음 코드를 추가로 추적하십시오.

$this->app['config']['view.compiled']

표준 라 라벨 구조를 사용하는 경우 일반적으로 /config/view.php에 있습니다.

<?php
return [
    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */
    'paths' => [
        resource_path('views'),
    ],
    /*
    |--------------------------------------------------------------------------
    | Compiled View Path
    |--------------------------------------------------------------------------
    |
    | This option determines where all the compiled Blade templates will be
    | stored for your application. Typically, this is within the storage
    | directory. However, as usual, you are free to change this value.
    |
    */
    'compiled' => realpath(storage_path('framework/views')),
];

경로가 없으면 realpath (...) 는 false를 반환합니다. 따라서 호출

'Please provide a valid cache path.' error.

따라서이 오류를 없애기 위해 할 수있는 일은

storage_path('framework/views')

또는

/storage/framework/views

존재 :)


다음을 시도하십시오 :

저장 / 프레임 워크에서 다음 폴더를 만듭니다.

  • 세션
  • 견해
  • cache/data

if still it does not work then try

php artisan cache:clear

if get an error of not able to clear cache. Make sure to create a folder data in cache/data


I solved this problem by adding this line in my index.php:

$app['config']['view.compiled'] = "storage/framework/cache";

Issue on my side(while deploying on localhost): there was views folder missing.. so if you have don't have the framework folder the you 'll need to add folders. but if already framework folder exist then make sure all above folders i.e 1. cache 2. session 3. views

exists in your framework directory.

참고URL : https://stackoverflow.com/questions/38483837/please-provide-a-valid-cache-path

반응형