Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Data is not returned using Volt. Possibly permission issue.

I am using Amazon linux instance. i have setup apache to be in the group file ownership. I setup app/cache to have 777 permissions. It seems to be working good until the moment when my controller returns data from Model to View via Volt:

    foreach($events as $event){

            $data[] = array(
                                'title' => $event->event_time,
                                'start' => $event->start_date,
                                'url' => UPDATE_URL . $event->appointment_id
            $eventData = json_encode($data, JSON_NUMERIC_CHECK);

            //Sending json to View
            $this->view->setVar('data', $eventData);

data variable returns nothing in the index.php file, even though DB is full of events. Checked cached volt file, i can see <?php echo $data;?> Even though when i load index.php has no events. This code works just fine on my Lamp locally on Windows. DB works fine, i was able to login using the user created in db.

I think i can still miss some permissions that need to be corrected.

Please advise, maybe i need to switch off caching?

edited May '16

tried to return just numbers

    $this->view->setVar('data', 123);

It did not help. Nothing on the page. That's why i think it's not related to getting data from db.

Which PhalconPHP version are you running? Phalcon 2.0.11 or below?


today cloned from Github, i think the most recent one

edited May '16

PHP Notice: Undefined variable: data in /var/www/html/booker/app/cache/_var_www_html_booker_app_views_calendar_index.volt.php on line 44, referer: http://.../booker/session/end

APACHE Error log


phalcon version is 2.0.12


on my local windows ver 2.0.9.

What php version you are using?


PHP 5.6.21 (cli) (built: May 2 2016 23:27:53)


you should not set 777 on your web folder, that's mean that anyone can w/r/x yours files...not so good so using 777 is not your problem Set the folders permissions to something more restrictive and case by case. First see the log of your database (/var/log/...) using tail ( tail -f /var/log/yourfile.log ) as your are using your app in browser, do the same with server log (for apache /var/log/apache2/error.log (another debian package is called multitail, and allow monitoring of more than one file at a time)


i set permissions back to 755 on cache folder. DB log shows the following:

InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
160516 17:14:55  InnoDB: Waiting for the background threads to start
160516 17:14:56 InnoDB: 5.5.46 started; log sequence number 0
160516 17:14:56 [Note] Server hostname (bind-address): ''; port: 3306
160516 17:14:56 [Note]   - '' resolves to '';
160516 17:14:56 [Note] Server socket created on IP: ''.
160516 17:14:56 [Note] Event Scheduler: Loaded 0 events
160516 17:14:56 [Note] /usr/libexec/mysql55/mysqld: ready for connections.
Version: '5.5.46'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

apache server log i provided above, which returns error that data variable that i am sending from Controller into view, is not defined. which is strange behaviour as it works fine on my local windows phalcon installation.

Post your routes.


Are the PHP versions different? PHP 5.6.21 on linux and 5.6.15 on my windows machine


do you mean app/config/routes.php?

edited May '16

Except if your DB log is not set to an enough verbose mode (see here: ), no connection attemps are logged here (just init procedure)...Your log (set at "statement level") should show each query from your controller (if you don't use caching)...

your php log saying $var is not defined let suppose that the query was first not done correctly (or not done), does "php -m" confirm that phalcon and DB related modules are loaded (do a check adding "phpinfo();" in your index php too, sometime the php cli version is not the same that the one apache use)


if volt file in cache is generated, that's means that controller have been reached, no?

do you mean app/config/routes.php?


Thnx goes to graphmatic!!! DB issue!!! Enabled general query and found the problematic query. Executed the query in phpmyAdmin which showed me that i refer to one of my tables with capitalized name, which worked fine on my Windows machine where i have Xampp and you can refer to tables both with capitalized names and lowercase(my case). This is not so on linux instance where i am hosting my app right now.

I added getSource method to my model class where i return lowecase name of my table. Issue is fixed. Thank you everybody and especially graphmatic

Another one with using Windows. Windows should be prohibited for developers. :)