I am using Phalcon and MySQL. Upon logging in I received an error like this,
Meta-Data directory cannot be written
#0 [internal function]: Phalcon\Mvc\Model\MetaData\Files->write('map-map\\models\\...', Array)
#1 [internal function]: Phalcon\Mvc\Model\MetaData->_initialize(Object(Map\Models\Users), NULL, NULL, NULL)
#2 [internal function]: Phalcon\Mvc\Model\MetaData->readColumnMapIndex(Object(Map\Models\Users), 1)
#3 [internal function]: Phalcon\Mvc\Model\MetaData->getReverseColumnMap(Object(Map\Models\Users))
#4 [internal function]: Phalcon\Mvc\Model::_invokeFinder('findFirstByUser...', Array)
#5 /var/www/html/app_map_system/app/library/Auth/Auth.php(27): Phalcon\Mvc\Model::__callStatic('findFirstByUser...', Array)
#6 /var/www/html/app_map_system/app/library/Auth/Auth.php(27): Map\Models\Users::findFirstByUsername('admin@admin.com')
#7 /var/www/html/app_map_system/app/controllers/IndexController.php(44): Map\Auth\Auth->check(Array)
#8 [internal function]: Map\Controllers\IndexController->loginAction()
#9 [internal function]: Phalcon\Dispatcher->callActionMethod(Object(Map\Controllers\IndexController), 'loginAction', Array)
#10 [internal function]: Phalcon\Dispatcher->dispatch()
#11 /var/www/html/app_map_system/public/index.php(41): Phalcon\Mvc\Application->handle()
#12 {main}
I have given access www-data as well as my user to /var/www/ directory using this command,
sudo chown -R www-data:www-data /var/www/
but still getting the same error. Anyone who encountered the same issue? Any help would be appreciated.
I had this same issue when I switched to Ubuntu. Here's how I solved it.
First, I realized that even after running a CHMod on my full project directory I always come across the write error for Meta-Data.
A portion of my DI code to configure Models Meta-Data:
$di -> set('modelsMetadata', function(){
$metaData = new MetaDataAdapter([
'metaDataDir' => APP_PATH . '/cache/metaData/'
]);
return $metaData;
});
Make sure the folder exists. Then using the Terminal, I do a cd command to my /app/cache/ folder. Once there, run: sudo chmod 755 metaData
Hope this helps...