Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Config cache in laravel 5 results in view not found

I'm tying to render a simple view:

public function test()
{
    return \View::make('test');
}

I cache my config :

$ php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!

When I run it in a web browser I've got :

InvalidArgumentException in FileViewFinder.php line 140:
View [test] not found.
in FileViewFinder.php line 140
at FileViewFinder->findInPaths('test', array('/XXXXXX/resources/views')) in FileViewFinder.php line 77
at FileViewFinder->find('test') in Factory.php line 145
at Factory->make('test') in Facade.php line 213
... (framework backtrace)

I clear config cache...

$ php artisan config:clear
Configuration cache cleared!

...View is rendered (it's a simple HTML view resources/views/test.blade.php)

Why does it only work without cache config ?

like image 555
rap-2-h Avatar asked Feb 23 '15 14:02

rap-2-h


People also ask

Where is Laravel config cache?

The cache configuration is located at config/cache. php . In this file you may specify which cache driver you would like used by default throughout your application. Laravel supports popular caching backends like Memcached and Redis out of the box.

How do I enable Laravel cache?

To enable Laravel caching services, first use the Illuminate\Contracts\Cache\Factory and Illuminate\Contracts\Cache\Repository, as they provide access to the Laravel caching services. The Factory contract gives access to all the cache drivers of your application.

What is the use of cache in Laravel?

By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects on the server's filesystem. For larger applications, it is recommended that you use a more robust driver such as Memcached or Redis. You may even configure multiple cache configurations for the same driver.

What is Laravel Memcached?

Adding caching to Laravel. Memcache is an in-memory, distributed cache. Its primary API consists of two operations: SET(key, value) and GET(key) . Memcache is like a hashmap (or dictionary) that is spread across multiple servers, where operations are still performed in constant time.


1 Answers

It does not work when your machine is running on vagrant (or another virtual environnement) and you run php artisan config:cache out of vagrant. Do you need to run this command in vagrant. The problem is about path routes (path are not the same in vagrant and out of vagrant).

like image 190
rap-2-h Avatar answered Oct 04 '22 20:10

rap-2-h