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

작동하는 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

존재 🙂


답변

“프레임 워크”안에 폴더를 만들어야합니다. 다음 단계를 따르십시오.

cd storage/
mkdir -p framework/{sessions,views,cache}

Laravel이이 디렉토리에 데이터를 쓸 수 있도록 권한을 설정해야합니다.

chmod -R 775 framework
chown -R www-data:www-data framework


답변

이 폴더를 만들지 않으면 다음 폴더가 있는지 확인하십시오.

  • 스토리지 / 프레임 워크 / 캐시
  • 저장 / 프레임 워크 / 세션
  • 저장 / 프레임 워크 / 테스트
  • 저장 / 프레임 워크 / 조회