kenjis / codeigniter-ss-twig

A Simple and Secure Twig integration for CodeIgniter 3.x and 4.x
MIT License
168 stars 46 forks source link

Unable to create the cache directory #28

Closed piotrfilipek closed 7 years ago

piotrfilipek commented 7 years ago

Hi, I want to display prepared twig template, but app shows me a message that unable to create cache directory.

An uncaught Exception was encountered

Type: RuntimeException

Message: Unable to create the cache directory (/usr/home/pfilipek/homewww/ci3-doctrine/application/cache/twig/42).

Filename: /usr/home/pfilipek/homewww/ci3-doctrine/vendor/twig/twig/lib/Twig/Cache/Filesystem.php

Line Number: 57

Backtrace:

File: /usr/home/pfilipek/homewww/ci3-doctrine/vendor/twig/twig/lib/Twig/Environment.php Line: 452 Function: write

File: /usr/home/pfilipek/homewww/ci3-doctrine/vendor/twig/twig/lib/Twig/Environment.php Line: 362 Function: loadTemplate

File: /usr/home/pfilipek/homewww/ci3-doctrine/application/libraries/Twig.php Line: 174 Function: render

File: /usr/home/pfilipek/homewww/ci3-doctrine/application/libraries/Twig.php Line: 156 Function: render

File: /usr/home/pfilipek/homewww/ci3-doctrine/application/controllers/Welcome.php Line: 55 Function: display

File: /usr/home/pfilipek/homewww/ci3-doctrine/index.php Line: 315 Function: require_once

cache directory exists and I setted permissions but it still doesn't work.

frost-byte commented 7 years ago

Is that the correct path? Is it supposed to have a / between home and www? Nevermind! I just double checked your full path name!

frost-byte commented 7 years ago

There are several places you can check for the configured cache.

  1. In your application/config/config.php

    /*
    |--------------------------------------------------------------------------
    | Cache Directory Path
    |--------------------------------------------------------------------------
    |
    | Leave this BLANK unless you would like to set something other than the default
    | application/cache/ directory.  Use a full server path with trailing slash.
    |
    */
    $config['cache_path'] = '';
  2. In the constructor of your Twig file.

In my case, this file has the path application/libraries/Twig.php and I have the following config there:

        $this->config = [
            'paths' =>array(VIEWPATH),
            'cache' => APPPATH . 'cache/twig',
            'auto_reload' => true
        ];
kenjis commented 7 years ago

cache directory exists and I setted permissions but it still doesn't work.

Please run the following command and show the result:

$ ls -l /usr/home/pfilipek/homewww/ci3-doctrine/application/cache/twig/