Phalcon Framework 3.4.5

ParseError: syntax error, unexpected end of file

/home/grijalva/apps/grijalva/grijalva/app/cache/volt/_home_grijalva_apps_grijalva_grijalva_app_views_products_prices.volt.php (257)
#0Phalcon\Mvc\View\Engine\Volt->render(/home/grijalva/apps/grijalva/grijalva/app/config/../../app/views/products/prices.volt, Array([appTitle] => Grijalva POS, [env] => PROD, [pageBreadcrumbs] => Array([0] => POS, [1] => Productos, [2] => Producto), [pageTitle] => Producto, [id] => 5100489, [price] => 49091, [data] => Array([product] => Object(Products), [prices] => Object(ProductPrices))), true)
#1Phalcon\Mvc\View->_engineRender(Array([.volt] => Object(Phalcon\Mvc\View\Engine\Volt), [.phtml] => Object(Phalcon\Mvc\View\Engine\Php)), products/prices, true, true, null)
#2Phalcon\Mvc\View->render(products, prices)
#3Phalcon\Mvc\Application->handle()
/home/grijalva/apps/grijalva/grijalva/app/config/bootstrap.php (121)
<?php
/**
 * Bootstraps the application
 */
use Phalcon\DI\FactoryDefault as PhDi;
use Phalcon\Config as PhConfig;
use Phalcon\Session\Adapter\Files as PhSession;
use Phalcon\Loader as PhLoader;
use Phalcon\Mvc\Url as PhUrl;
use Phalcon\Mvc\Router as PhRouter;
use Phalcon\Mvc\Application as PhApplication;
use Phalcon\Mvc\View as PhView;
use Phalcon\Mvc\View\Engine\Volt as PhVolt;
use Phalcon\Mvc\Model\Metadata\Memory as PhMetadataMemory;
use Phalcon\Cache\Frontend\Output as PhCacheFront;
use Phalcon\Cache\Backend\File as PhCacheBackFile;
use Phalcon\Cache\Backend\Apc as PhCacheBackApc;
use Phalcon\Db\Adapter\Pdo\Mysql as PhMysql;
use Phalcon\Exception as PhException;
use Phalcon\Logger as PhLogger;
use Phalcon\Logger\Adapter\File as PhLogFileAdapter;
use Phalcon\Debug as PhDebug;
use Phalcon\Dispatcher;
use Phalcon\Mvc\Dispatcher as MvcDispatcher;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Mvc\Dispatcher\Exception as DispatchException;
 
class Bootstrap
{
    private $di;
 
    /**
    * Constructor
    *
    * @param $di
    */
    public function __construct($di)
    {
        $this->di = $di;
    }
 
    /**
    * Runs the application performing all initializations
    *
    * @param $options
    *
    * @return mixed
    */
    public function run($options)
    {
        $loaders = array(
            'config',
            'session',
            'loader',
            'url',
            'router',
            'database',
            'view',
            'cache',
            'log',
            'utils',
            'debug'
        );
 
        try {
 
            // Handing missing controller errors
            $this->di->set('dispatcher', function () {
 
                //Create an EventsManager
                $eventsManager = new EventsManager();
 
                // Attach a listener
                $eventsManager->attach("dispatch:beforeException", function ($event, $dispatcher, $exception) {
 
                    // Handle 404 exceptions
                    if ($exception instanceof DispatchException) {
                        $dispatcher->forward(array(
                            'controller' => 'index',
                            'action' => 'internalServerError'
                        ));
                        return false;
                    }
 
                    // Alternative way, controller or action doesn't exist
                    if ($event->getType() == 'beforeException') {
                        switch ($exception->getCode()) {
                            case \Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                            case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                                $dispatcher->forward(array(
                                    'controller' => 'index',
                                    'action' => 'internalServerError'
                                ));
                                return false;
                        }
                    }
                });
 
                // Instantiate the Security plugin
                $security = @new Security($di);
 
                // Listen for events produced in the dispatcher using the Security plugin
                $eventsManager->attach('dispatch', $security);
 
                $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
                // Bind the EventsManager to the dispatcher
                $dispatcher->setEventsManager($eventsManager);
 
                return $dispatcher;
            }, true);
 
            foreach ($loaders as $service) {
                $function = 'init' . ucfirst($service);
                $this->$function();
            }
 
            $application = new PhApplication();
            $application->setDI($this->di);
 
            return $application->handle()->getContent();
            //return $application->handle($_SERVER["REQUEST_URI"]);
        } catch (PhException $e) {
            echo $e->getMessage();
        } catch (\PDOException $e) {
            echo $e->getMessage();
        }
    }
 
    /**
    * Initializes the config. Reads it from its location and
    * stores it in the Di container for easier access
    *
    * @param array $options
    */
    protected function initConfig($options = array())
    {
        $configFile = require(ROOT_PATH . '/app/config/config.php');
 
        // Create the new object
        $config = new PhConfig($configFile);
 
        // Store it in the Di container
        // Settings cones from the include
        $this->di['config'] = $config;
    }
 
    // Protected functions
    /**
    * Initializes the session
    *
    * @param array $options
    */
    protected function initSession($options = array())
    {
        $config = $this->di['config'];
 
        $this->di['session'] = function () use ($config) {
            $session = new PhSession(array(
                'uniqueId' => $config->application->appName
            ));
 
            $session->start();
 
            return $session;
        };
    }
 
    /**
    * Initializes the loader
    *
    * @param array $options
    */
    protected function initLoader($options = array())
    {
        $config = $this->di['config'];
 
        // Creates the autoloader
        $loader = new PhLoader();
 
        $loader->registerDirs(
            array(
                $config->application->helpersDir,
                $config->application->repositoriesDir,
                $config->application->servicesDir,
 
                $config->application->controllersDir,
                $config->application->libraryDir,
                $config->application->modelsDir,
                $config->application->pluginsDir,
                $config->application->vendorDir
            )
        );
 
/* 20240909: add - name spaces
*/      $loader->registerNamespaces(
            [
                'App\Models' => $config->application->modelsDir,
                'App\Services' => $config->application->servicesDir,
                'App\Repositories' => $config->application->repositoriesDir,
                'App\Helpers' => $config->application->helpersDir,
            ]
        );
 
        $loader->registerClasses(
            array(
            )
        );
 
        $loader->registerFiles(
            array(
                $config->application->vendorDir . '/autoload.php'
            )
        );
 
        $loader->register();
 
        // Dump it in the DI to reuse it
        $this->di['loader'] = $loader;
    }
 
    /**
    * Initializes the baseUrl
    *
    * @param array $options
    */
    protected function initUrl($options = array())
    {
        $config = $this->di['config'];
 
        /**
        * The URL component is used to generate all kind of urls in the
        * application
        */
        $this->di['url'] = function () use ($config) {
            $url = new PhUrl();
            $url->setBaseUri($config->application->baseUri);
            return $url;
        };
    }
 
    /**
    * Initializes the router
    *
    * @param array $options
    */
    protected function initRouter($options = array())
    {
        $config = $this->di['config'];
 
        $this->di['router'] = function () use ($config) {
 
            // Create the router without default routes (false)
            $router = new PhRouter(true);
 
            // 404
            $router->notFound(
                array(
                    "controller" => "index",
                    "action"     => "notFound",
                )
            );
            $router->removeExtraSlashes(true);
 
            foreach ($config['routes'] as $route => $items) {
                $router->add($route, $items->params->toArray())->setName($items->name);
            }
 
            return $router;
        };
    }
 
    /**
    * Initializes the database
    *
    * @param array $options
    */
    protected function initDatabase($options = array())
    {
        $config = $this->di['config'];
 
        // setup database service
        $this->di['db'] = function () use ($config) {
            $connection = new PhMysql(
                array(
                    'host'     => $config->database->host,
                    'username' => $config->database->username,
                    'password' => $config->database->password,
                    'dbname'   => $config->database->dbname,
                    'charset'  => $config->database->charset
                )
            );
 
            // log sql statements
            if ('1' == $config->application->debug) {
                $eventsManager = new EventsManager();
 
                $logger = new PhLogFileAdapter($config->application->logDir . "/db.log");
 
                //Listen all the database events
                $eventsManager->attach('db', function ($event, $connection) use ($logger) {
                    if ($event->getType() == 'beforeQuery') {
                        $logger->log($connection->getSQLStatement(), \Phalcon\Logger::INFO);
                    }
                });
 
                // Assign the eventsManager to the db adapter instance
                $connection->setEventsManager($eventsManager);
            }
 
            return $connection;
        };
    }
 
    /**
    * Initializes the models metadata
    *
    * @param array $options
    */
    protected function initModelsMetadata($options = array())
    {
        $this->di['modelsMetadata'] = function () {
            return new PhMetadataMemory();
        };
    }
 
    /**
    * Initializes the view and Volt
    *
    * @param array $options
    */
    protected function initView($options = array())
    {
        $config = $this->di['config'];
        $di     = $this->di;
 
        /**
        * Setup the view service
        */
        $this->di['view'] = function () use ($config, $di) {
            $view = new PhView();
            $view->setViewsDir($config->application->viewsDir);
            $view->registerEngines(
                array(
                    '.volt' => function ($view, $di) use ($config) {
                        $volt        = new PhVolt($view, $di);
                        $voltOptions = array(
                            'compiledPath'      => $config->application->voltDir,
                            'compiledSeparator' => '_',
                        );
 
                        if ('1' == $config->application->debug) {
                            $voltOptions['compileAlways'] = true;
                        }
 
                        $volt->setOptions($voltOptions);
                        $volt->getCompiler()->addFunction(
                            'tr',
                            function ($key) {
                                return "Bootstrap::translate({$key})";
                            }
                        );
 
                        return $volt;
                    },
                    '.phtml' => 'Phalcon\Mvc\View\Engine\Php', // Generate Template files uses PHP itself as the template engine
                )
            );
 
            return $view;
        };
    }
 
    /**
     * Initializes the cache
     *
     * @param array $options
     */
    protected function initCache($options = array())
    {
        $config = $this->di['config'];
 
        $this->di['viewCache'] = function () use ($config) {
 
            // Get the parameters
            $frontCache      = new PhCacheFront(array('lifetime' => $config->cache->lifetime));
 
            if (function_exists('apc_store')) {
                $cache = new PhCacheBackApc($frontCache);
            } else {
                $backEndOptions = array('cacheDir' => $config->cache->cacheDir);
                $cache          = new PhCacheBackFile($frontCache, $backEndOptions);
            }
 
            return $cache;
        };
    }
 
    // Protected functions
    /**
    * Initializes the file logger
    *
    * @param array $options
    */
    protected function initLog($options = array())
    {
        $config = $this->di['config'];
 
        $this->di['logger'] = function () use ($config) {
            $logger = new PhLogFileAdapter($config->application->logDir . "/app.log");
 
            return $logger;
        };
    }
 
    // Protected functions
    /**
    * Initializes the utilities
    *
    * @param array $options
    */
    protected function initUtils($options = array())
    {
        $config = $this->di['config'];
 
        // get all the files in app/utils directory
        if ($handle = opendir($config->application->utilsDir)) {
            while (false !== ($entry = readdir($handle))) {
                if ($entry != "." && $entry != "..") {
                    include_once $config->application->utilsDir . "/{$entry}";
                }
            }
 
            closedir($handle);
        }
    }
 
    /**
    * Initializes debug
    *
    * @param array $options
    */
    protected function initDebug($options = array())
    {
        $config = $this->di['config'];
 
        // Create the new object
        $debug = new PhDebug();
 
        // Store it in the Di container
        // Settings cones from the include
        if ('1' == $config->application->debug) {
            $debug->listen();
        }
        $this->di['debug'] = $debug;
    }
 
    /**
     * Register the flash service with custom CSS classes
     */
    protected function initFlash()
    {
        return new FlashSession([
            'error' => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
            'warning' => 'alert alert-warning'
        ]);
    }
 
    /**
     * Translates a string
     *
     * @return string
     */
    public static function translate()
    {
        $return     = '';
        $messages   = array();
        $argCount   = func_num_args();
        $di         = PhDi::getDefault();
        $session    = $di['session'];
        $config     = $di['config'];
        $dispatcher = $di['dispatcher'];
        $lang       = $dispatcher->getParam('language');
 
        if (function_exists('apc_store')) {
            $phrases    = apc_fetch($lang . '-phrases');
            $language   = apc_fetch($lang . '-language');
        } else {
            $phrases    = $session->get('phrases');
            $language   = $session->get('language');
        }
 
        $changed = false;
        if (!$phrases || $language != $lang || ('1' == $config->application->debug)) {
            require ROOT_PATH . '/app/var/languages/en.php';
 
            /**
             * Messages comes from the above require statement. Not the best
             * way of doing it but we need this for Transilex
             */
            $english = $messages;
            $phrases = $english;
            if ('en' !== $lang) {
                if (file_exists(ROOT_PATH . '/app/var/languages/' . $lang . '.php')) {
 
                    /**
                     * Cleanup
                     */
                    $messages = array();
                    require ROOT_PATH . '/app/var/languages/' . $lang . '.php';
 
                    /**
                     * Messages comes from the above require statement. Not
                     * the best way of doing it but we need this for Transilex
                     */
                    $custom  = $messages;
 
                    foreach ($english as $key => $value) {
                        $phrases[$key] = (!empty($custom[$key])) ? $custom[$key] : $value;
                    }
                }
 
                $changed = true;
            }
 
            if ($changed) {
                if (function_exists('apc_store')) {
                    apc_store($lang . '-phrases', $phrases);
                    apc_store($lang . '-language', $lang);
                } else {
                    $session->set('phrases', $phrases);
                    $session->set('language', $lang);
                }
            }
        }
 
        // If parameters were passed process them, otherwise return an
        // empty string
        if ($argCount > 0) {
            $arguments = func_get_args();
 
            // The first argument is the key
            $key = $arguments[0];
 
            if (isset($phrases[$key])) {
                $return = $phrases[$key];
 
                // Any subsequent arguments need to replace placeholders
                // in the target string. Unset the key and process the
                // rest of the arguments one by one.
                unset($arguments[0]);
 
                foreach ($arguments as $key => $argument) {
                    $return = str_replace(":{$key}:", $argument, $return);
                }
            }
        }
 
        return $return;
    }
}
#4Bootstrap->run(null)
/home/grijalva/apps/grijalva/grijalva/public/index.php (37)
<?php
ini_set('display_errors', 1);
ini_set('max_execution_time', '0');
 
date_default_timezone_set('America/Mexico_City');
 
use \Phalcon\DI\FactoryDefault as PhDi;
 
error_reporting(E_ALL);
 
if (!defined('ROOT_PATH')) {
    define('ROOT_PATH', dirname(dirname(__FILE__)));
}
 
try {
 
    /**
     * Read services (bootstrap)
     */
    include __DIR__ . "/../app/config/bootstrap.php";
 
    /**
     * Create a DI container
     */
    $di = new PhDi();
 
    /**
     * Include services
     */
    include __DIR__ . "/../app/config/services.php";
 
    /**
     * Handle the request
     */
    $app = new Bootstrap($di);
 
    echo $app->run(array());
 
} catch (\Phalcon\Exception $e) {
    echo $e->getMessage();
} catch (PDOException $e){
    echo $e->getMessage();
}
KeyValue
_url/products/prices/5100489/49091
KeyValue
PHP_INI_SCAN_DIR/etc/php.d/:/home/grijalva/apps/grijalva/
USERgrijalva
HOME/home/grijalva
SCRIPT_NAME/grijalva/public/index.php
REQUEST_URI/grijalva/products/prices/5100489/49091
QUERY_STRING_url=/products/prices/5100489/49091
REQUEST_METHODGET
SERVER_PROTOCOLHTTP/1.1
GATEWAY_INTERFACECGI/1.1
REDIRECT_URL/grijalva/public/products/prices/5100489/49091
REDIRECT_QUERY_STRING_url=/products/prices/5100489/49091
REMOTE_PORT56474
SCRIPT_FILENAME/home/grijalva/apps/grijalva/grijalva/public/index.php
SERVER_ADMIN[no address given]
CONTEXT_DOCUMENT_ROOT/home/grijalva/apps/grijalva/
CONTEXT_PREFIX/
REQUEST_SCHEMEhttp
DOCUMENT_ROOT/home/grijalva/apps/grijalva
REMOTE_ADDR3.145.109.53
SERVER_PORT80
SERVER_ADDR127.0.0.1
SERVER_NAMEgrijalva.mx
SERVER_SOFTWAREApache
SERVER_SIGNATURE<address>Apache Server at grijalva.mx Port 80</address>\n
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
HTTP_ACCEPT_ENCODINGgzip, br, zstd, deflate
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT*/*
HTTP_CONNECTIONupgrade
HTTP_X_FORWARDED_SSLon
HTTP_X_FORWARDED_PROTOhttps
HTTP_HTTPSon
HTTP_FORWARDED_REQUEST_URI/grijalva/products/prices/5100489/49091
HTTP_X_FORWARDED_SERVERgrijalva.mx
HTTP_X_FORWARDED_HOSTgrijalva.mx
HTTP_HOSTgrijalva.mx
proxy-nokeepalive1
HTTPSon
UNIQUE_IDaAfH9tr2KXaQ@9IcbX2cJAAAAEM
REDIRECT_STATUS200
REDIRECT_HTTPSon
REDIRECT_UNIQUE_IDaAfH9tr2KXaQ@9IcbX2cJAAAAEM
REDIRECT_REDIRECT_STATUS200
REDIRECT_REDIRECT_HTTPSon
REDIRECT_REDIRECT_UNIQUE_IDaAfH9tr2KXaQ@9IcbX2cJAAAAEM
FCGI_ROLERESPONDER
PHP_SELF/grijalva/public/index.php
REQUEST_TIME_FLOAT1745340406.911
REQUEST_TIME1745340406
#Path
0/home/grijalva/apps/grijalva/grijalva/public/index.php
1/home/grijalva/apps/grijalva/grijalva/app/config/bootstrap.php
2/home/grijalva/apps/grijalva/grijalva/app/config/services.php
3/home/grijalva/apps/grijalva/grijalva/app/config/config.php
4/home/grijalva/apps/grijalva/grijalva/app/vendor/autoload.php
5/home/grijalva/apps/grijalva/grijalva/app/vendor/composer/autoload_real.php
6/home/grijalva/apps/grijalva/grijalva/app/vendor/composer/platform_check.php
7/home/grijalva/apps/grijalva/grijalva/app/vendor/composer/ClassLoader.php
8/home/grijalva/apps/grijalva/grijalva/app/vendor/composer/autoload_static.php
9/home/grijalva/apps/grijalva/grijalva/app/vendor/symfony/polyfill-php80/bootstrap.php
10/home/grijalva/apps/grijalva/grijalva/app/vendor/symfony/polyfill-mbstring/bootstrap.php
11/home/grijalva/apps/grijalva/grijalva/app/vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php
12/home/grijalva/apps/grijalva/grijalva/app/vendor/myclabs/deep-copy/src/DeepCopy/deep_copy.php
13/home/grijalva/apps/grijalva/grijalva/app/utils/basics.php
14/home/grijalva/apps/grijalva/grijalva/app/plugins/Security.php
15/home/grijalva/apps/grijalva/grijalva/app/controllers/ProductsController.php
16/home/grijalva/apps/grijalva/grijalva/app/controllers/ControllerBase.php
17/home/grijalva/apps/grijalva/grijalva/app/models/Products.php
18/home/grijalva/apps/grijalva/grijalva/app/models/ProductPrices.php
19/home/grijalva/apps/grijalva/grijalva/app/cache/volt/_home_grijalva_apps_grijalva_grijalva_app_views_products_prices.volt.php
Memory
Usage2097152