snowair / phalcon-debugbar

A powerful debug and profilers tool for the Phalcon Framework
MIT License
162 stars 49 forks source link

404 error for static files #20

Closed panaceya closed 8 years ago

panaceya commented 8 years ago

I use default INVO with your plug-in, but receive errors:

"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/stylesheets?1445286912"
stylesh...5286912
"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/javascript?1445286912"
javascr...5286912
"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/stylesheets?1445286912"
stylesh...5286912
"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/javascript?1445286912"

my public.index.php

<?php
error_reporting(E_ALL);

use Phalcon\Mvc\Application;
use Phalcon\Config\Adapter\Ini as ConfigIni;

try {
    define('APP_PATH', realpath('..') . '/');

    $config = new ConfigIni(APP_PATH . 'app/config/config.ini');
    if (is_readable(APP_PATH . 'app/config/config.ini.dev')) {
        $override = new ConfigIni(APP_PATH . 'app/config/config.ini.dev');
        $config->merge($override);
    }
    require APP_PATH . 'app/config/loader.php';
    require APP_PATH . 'app/config/services.php';

    $application = new Application($di);
    $di['app'] = $application;
    (new Snowair\Debugbar\ServiceProvider())->start();

    echo $application->handle()->getContent();
} catch (Exception $e){
    echo $e->getMessage() . '<br>';
    echo '<pre>' . $e->getTraceAsString() . '</pre>';
}

my app/confing/loader.php

<?php
require_once __DIR__ . '/../../vendor/autoload.php';
$loader = new \Phalcon\Loader();
$loader->registerDirs(
    array(
        APP_PATH . $config->application->controllersDir,
        APP_PATH . $config->application->pluginsDir,
        APP_PATH . $config->application->libraryDir,
        APP_PATH . $config->application->modelsDir,
        APP_PATH . $config->application->formsDir,
    )
)->register();

Any ideas?

snowair commented 8 years ago

please check your baseUri config.

panaceya commented 8 years ago

All settings correct

value baseUri set to '/' in my config.ini, and file app/config/services.php have this content:

$di->set('url', function() use ($config){
    $url = new Phalcon\Mvc\Url();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
snowair commented 8 years ago

Check your web server config.

This is my demo source : https://git.coding.net/snowair/invo.git

You can edit index.php and loader.php of this demo for your test.

panaceya commented 8 years ago

Demo source from https://git.coding.net/snowair/invo.git worked nicely.

snowair commented 8 years ago

app/plugins/SecurityPlugin.php :

 public function beforeDispatch(Event $event, Dispatcher $dispatcher)
    {
        $auth = $this->session->get('auth');
        if (!$auth){
            $role = 'Guests';
        } else {
            $role = 'Users';
        }
        $controller = $dispatcher->getControllerName();
        $action = $dispatcher->getActionName();
        $ns = $dispatcher->getNamespaceName();
        if ($ns=='Snowair\Debugbar\Controllers') {
            return true;
        }
        $acl = $this->getAcl();
        $allowed = $acl->isAllowed($role, $controller, $action);
        if ($allowed != Acl::ALLOW) {
            $dispatcher->forward(array(
                'controller' => 'errors',
                'action'     => 'show401'
            ));
                        $this->session->destroy();
            return false;
        }
    }