Reputation: 922
The error I am getting is
Warning: Phalcon\Mvc\View\Engine\Volt\Compiler::compileFile(../app/views/index/index.phtml.php): failed to open stream: Permission denied in /Users/mattstephens/Sites/magpie/public/index.php on line 26 Phalcon Exception: Volt directory can't be written
I have declared the volt engine usage in my bootstrap like so
$view->registerEngines(array(
'.phtml' => 'Phalcon\Mvc\View\Engine\Volt'
));
The mention of line 26 in my code points to the application handle function shown below
echo $application->handle()->getContent();
Is this a permissions related thing or due to a missing directory?
Upvotes: 6
Views: 20789
Reputation: 107
Check if the baseUri
in the config.php
is same as the installation directory
if the issue persist, tail nginx logs tail -f /var/log/nginx/*.log
.
Also try use sudo setenforce 0
. This worked for me.
Upvotes: 0
Reputation: 41
You should change ownership of your project directory with chown command,
chown -R your_system_user:webserver_user yourproject/
Upvotes: 1
Reputation: 11
Just go to /project_name/store/app/config/config.php and change cacheDir from 'cacheDir' => __DIR__ . '/../../app/cache/' to 'cacheDir' => __DIR__ . '/../../cache/'.
Also, change its write permission to 777.
Upvotes: 0
Reputation: 2470
Contrary to several of the other answers here, don't just willy-nilly set permissions to 0777 and pretend everything's okay, that's completely ridiculous. Your server needs to write to the volt folder inside your cache directory.
You might need to create the folder first.
sudo mkdir cache
, and sudo mkdir cache/volt
. Then chown that folder with whatever is the username that your server runs.
NOTE: Depending on your configuration, the cache
folder might be located at the project root and not inside app
.
For example, if your server launches under the permissions of user named 'www-data' (which is most common), after creating the proper folder structure, the following command will fix your issue:
sudo chown www-data:www-data -R cache
Upvotes: 6
Reputation: 480
Changing the app/cache and app/cache/volt with these commands worked for my project structure.
chmod -R a+w app/cache
chmod -R a+w app/cache/volt
Upvotes: 0
Reputation: 59
Change volt file permission (Inside app/cache) to 777 .Its working fine
Upvotes: 6
Reputation: 51
change the "app/cache" folder permission to 777. in my mac i did like this.
Upvotes: 2
Reputation: 423
I have just made "app/cache" folder with 777 permitions) It works))
Upvotes: 2
Reputation: 11485
Unless you specify a different folder for Volt to compile its templates, the folder where the view file is located will be used to create the relevant compiled file.
You can change this behavior by setting the proper option when you register your service as such:
use \Phalcon\Mvc\View as PhView;
use \Phalcon\Mvc\View\Engine\Volt as PhVolt;
...
public function initView($options = array())
{
$config = $this->di['config'];
$di = $this->di;
$this->di['volt'] = function ($view, $di) use ($config) {
$volt = new PhVolt($view, $di);
$volt->setOptions(
array(
'compiledPath' => $config->app_volt->path,
'compiledExtension' => $config->app_volt->extension,
'compiledSeparator' => $config->app_volt->separator,
'stat' => (bool) $config->app_volt->stat,
)
);
return $volt;
};
/**
* Setup the view service
*/
$this->di['view'] = function () use ($config, $di) {
$view = new PhView();
$view->setViewsDir($config->app_path->views);
$view->registerEngines(array('.volt' => 'volt'));
return $view;
};
}
The $config
will store all the information you need. By using the compiledPath
you instruct Volt to compile the templates there and then serve them to the front end. That folder needs to be writeable for the user that runs your web server www-data
or other and can be outside your public folder.
The file structure I usually use is:
app
\controllers
\models
\views
public
\js
\css
\img
var
\volt
\logs
\config
\cache
Upvotes: 7