Framework: [5.0][5.1] 4.2μ—μ„œ μ—…κ·Έλ ˆμ΄λ“œ ν›„ μΊμ‹œ 문제

에 λ§Œλ“  2016λ…„ 01μ›” 05일  Β·  3μ½”λ©˜νŠΈ  Β·  좜처: laravel/framework

μ•ˆλ…• !
1λ…„ λ„˜κ²Œ laravel 4.2λ₯Ό μ‹€ν–‰ν•˜λŠ” ν”„λ‘œμ νŠΈκ°€ μžˆμŠ΅λ‹ˆλ‹€.
이번 주에 5.0을 μ‚¬μš©ν•œ λ‹€μŒ 5.1을 μ‚¬μš©ν•˜λ„λ‘ μ—…κ·Έλ ˆμ΄λ“œ ν”„λ‘œμ„ΈμŠ€λ₯Ό μ‹œμž‘ν–ˆμœΌλ©° ꢁ극적으둜 5.2λ₯Ό λͺ©ν‘œλ‘œ ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

5.0 μ—…κ·Έλ ˆμ΄λ“œλŠ” 잘 λ˜μ—ˆκ³  이 캐싱 문제λ₯Ό μ œμ™Έν•˜κ³ λŠ” λͺ¨λ“  것이 μ™„λ²½ν•˜κ²Œ μž‘λ™ν–ˆμŠ΅λ‹ˆλ‹€.
μ²˜μŒμ—λŠ” "5.1둜 μ—…κ·Έλ ˆμ΄λ“œν•˜κ³  μž‘λ™ν•˜λŠ”μ§€ ν™•μΈν•˜μž"라고 μƒκ°ν–ˆμ§€λ§Œ 그렇지 μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

μΊμ‹œλ₯Ό μƒμ„±ν•˜κ³  이 μ˜ˆμ™Έκ°€ λ°œμƒν•˜λŠ” μž₯인 λͺ…령을 μ‚¬μš©ν•©λ‹ˆλ‹€.

Refreshing the message cache...

  [InvalidArgumentException]
  Cache store [] is not defined.

μ²˜μŒμ—λŠ” μ„€μΉ˜ 문제라고 μƒκ°ν–ˆμŠ΅λ‹ˆλ‹€. laravel 곡식 λ¬Έμ„œ κ°€μ΄λ“œμ— 따라 μ²˜μŒλΆ€ν„° λͺ¨λ“  것을 λ‹€μ‹œ μ„€μΉ˜ν–ˆμŠ΅λ‹ˆλ‹€. λͺ¨λ“  ꡬ성 등을 두 번 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€. ν•˜μ§€λ§Œ μ—¬μ „νžˆ 이 λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€.

μž¬μƒμ‚°/도움이 될 수 μžˆλŠ” 정보가 μžˆμŠ΅λ‹ˆλ‹€.

μž‘κ³‘κ°€.json μ½˜ν…μΈ :

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.1.*",
        "illuminate/html": "5.*",
        "andywer/js-localization": "dev-laravel-5",
        "laracasts/flash" : "~1.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database",
            "app/Models",
            "app/Http/Controllers"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

_cache.php_ μ„€μ • 파일:

<?php

return array(

    /*
    |--------------------------------------------------------------------------
    | Default Cache Driver
    |--------------------------------------------------------------------------
    |
    | This option controls the default cache "driver" that will be used when
    | using the Caching library. Of course, you may use other drivers any
    | time you wish. This is the default when another is not specified.
    |
    | Supported: "file", "database", "apc", "memcached", "redis", "array"
    |
    */

    'driver' => 'file',

    /*
    |--------------------------------------------------------------------------
    | Cache Stores
    |--------------------------------------------------------------------------
    |
    | Here you may define all of the cache "stores" for your application as
    | well as their drivers. You may even define multiple stores for the
    | same cache driver to group types of items stored in your caches.
    |
    */
    'stores' => [
        'apc' => [
            'driver' => 'apc',
        ],
        'array' => [
            'driver' => 'array',
        ],
        'database' => [
            'driver' => 'database',
            'table'  => 'cache',
            'connection' => 'mysql',
        ],
        'file' => [
            'driver' => 'file',
            'path'   => storage_path('framework/cache'),
        ],
        'memcached' => [
            'driver'  => 'memcached',
            'servers' => [
                [
                    'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100,
                ],
            ],
        ],
        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Cache Key Prefix
    |--------------------------------------------------------------------------
    |
    | When utilizing a RAM based store such as APC or Memcached, there might
    | be other applications utilizing the same cache. So, we'll specify a
    | value to get prefixed to all our keys so we can avoid collisions.
    |
    */
    'prefix' => 'laravel',

);

이 문제λ₯Ό μ„€λͺ…ν•˜κΈ° μœ„ν•΄ λ‚΄ ν™ˆ νŽ˜μ΄μ§€μ—μ„œ κ°„λ‹¨ν•œ μΊμ‹œ μ‚¬μš© 사둀λ₯Ό μ‹œλ„ν–ˆμŠ΅λ‹ˆλ‹€.

        public function index()
    {
        Cache::put('toto', 'titi', 1);
        $value = Cache::get('toto');
        return View::make('pages.accueil');
    }

λ‹€μŒμ€ λΈŒλΌμš°μ €μ—μ„œ 얻은 호좜 μŠ€νƒμž…λ‹ˆλ‹€(λ‚΄ νŒŒμΌμ—μ„œ μ „λ‹¬λ˜λŠ” μœ„μΉ˜λ₯Ό μž˜λΌλƒ…λ‹ˆλ‹€).

Whoops, looks like something went wrong.

1/1
InvalidArgumentException in CacheManager.php line 93:
Cache store [] is not defined.
in CacheManager.php line 93
at CacheManager->resolve(null) in CacheManager.php line 77
at CacheManager->get(null) in CacheManager.php line 55
at CacheManager->store() in CacheManager.php line 318
at CacheManager->__call('put', array('toto', 'titi', '1')) in Facade.php line 222
at CacheManager->put('toto', 'titi', '1') in Facade.php line 222
at Facade::__callStatic('put', array('toto', 'titi', '1')) in AccueilController.php line 13
at Cache::put('toto', 'titi', '1') in AccueilController.php line 13
at AccueilController->index()

λˆ„κ΅¬λ“ μ§€ 이미 이런 μ’…λ₯˜μ˜ 버그에 μ§λ©΄ν–ˆκ±°λ‚˜ μ‹œλ„ν•  방법이 μžˆμŠ΅λ‹ˆκΉŒ?
ν•„μš”ν•œ 경우 더 ꡬ체적인 μ„ΈλΆ€ 정보λ₯Ό μ œκ³΅ν•  수 μžˆμŠ΅λ‹ˆλ‹€. =)

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

μ•Œκ² μŠ΅λ‹ˆλ‹€. μ œκ°€ 정말 바보인 것 κ°™μ•„μš”. λˆ„κ΅°κ°€κ°€ λ‚˜μ²˜λŸΌ 이 "덫"에 빠진 경우 μ†”λ£¨μ…˜μ„ κ²Œμ‹œν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.

  • Laravel 4.2 μ—μ„œ κΈ°λ³Έ μΊμ‹œ λ“œλΌμ΄λ²„μ˜ ꡬ성 ν‚€λŠ” 예λ₯Ό λ“€μ–΄ "driver" => "file" μž…λ‹ˆλ‹€.
  • Laravel 5.x μ—μ„œ 이 ν‚€μ˜ 이름은 "default" => "file" μž…λ‹ˆλ‹€.

λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ν•˜λŠ” λ™μ•ˆ μƒˆ ν‚€/ꡬ성을 ν™•μΈν•˜κΈ° μœ„ν•΄ ν‚€λ³„λ‘œ ꡬ성 μ½˜ν…μΈ λ₯Ό λ³€κ²½ν–ˆμ§€λ§Œ 이 μ„ΈλΆ€ 정보λ₯Ό λ†“μ³€μŠ΅λ‹ˆλ‹€. κ·Έλž˜μ„œ "default" => "file" λŒ€μ‹  "driver" => "file" λ₯Ό 5.1에 가지고 μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

λͺ¨λ“  3 λŒ“κΈ€

ν¬λŸΌμ— μ§ˆλ¬Έν•˜μ‹­μ‹œμ˜€.

μ•Œκ² μŠ΅λ‹ˆλ‹€. μ œκ°€ 정말 바보인 것 κ°™μ•„μš”. λˆ„κ΅°κ°€κ°€ λ‚˜μ²˜λŸΌ 이 "덫"에 빠진 경우 μ†”λ£¨μ…˜μ„ κ²Œμ‹œν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.

  • Laravel 4.2 μ—μ„œ κΈ°λ³Έ μΊμ‹œ λ“œλΌμ΄λ²„μ˜ ꡬ성 ν‚€λŠ” 예λ₯Ό λ“€μ–΄ "driver" => "file" μž…λ‹ˆλ‹€.
  • Laravel 5.x μ—μ„œ 이 ν‚€μ˜ 이름은 "default" => "file" μž…λ‹ˆλ‹€.

λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ν•˜λŠ” λ™μ•ˆ μƒˆ ν‚€/ꡬ성을 ν™•μΈν•˜κΈ° μœ„ν•΄ ν‚€λ³„λ‘œ ꡬ성 μ½˜ν…μΈ λ₯Ό λ³€κ²½ν–ˆμ§€λ§Œ 이 μ„ΈλΆ€ 정보λ₯Ό λ†“μ³€μŠ΅λ‹ˆλ‹€. κ·Έλž˜μ„œ "default" => "file" λŒ€μ‹  "driver" => "file" λ₯Ό 5.1에 가지고 μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

3λ…„ 후에도 μ˜¬λ°”λ₯Έ μΈμˆ˜κ°€ μ œκ³΅λ˜μ—ˆλŠ”μ§€ ν™•μΈν•˜κΈ° μœ„ν•΄ .env νŒŒμΌμ„ λ‹€μ‹œ ν™•μΈν•˜μ‹­μ‹œμ˜€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰