Помогите с include(TbWidget.php): failed to open stream

Предварительное обсуждение найденных ошибок перед отправкой их авторам фреймворка, а также внесение новых предложений.
Ответить
Аватара пользователя
wokster
Сообщения: 308
Зарегистрирован: 2013.09.06, 14:12
Контактная информация:

Помогите с include(TbWidget.php): failed to open stream

Сообщение wokster »

Подключил yiistrap согласно инструкция на оф сайте. Все работает кроме виджетов. Выдает ошибку:
include(TbWidget.php): failed to open stream: No such file or directory

вот она полностью

Код: Выделить всё

PHP warning

 include(TbWidget.php): failed to open stream: No such file or directory 

C:\xampp\htdocs\yii\framework\YiiBase.php(427)
415                         {
416                             include($classFile);
417                             if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php')
418                                 throw new CException(Yii::t('yii','Class name "{class}" does not match class file "{file}".', array(
419                                     '{class}'=>$className,
420                                     '{file}'=>$classFile,
421                                 )));
422                             break;
423                         }
424                     }
425                 }
426                 else
427                     include($className.'.php');
428             }
429             else  // class name with namespace in PHP 5.3
430             {
431                 $namespace=str_replace('\\','.',ltrim($className,'\\'));
432                 if(($path=self::getPathOfAlias($namespace))!==false)
433                     include($path.'.php');
434                 else
435                     return false;
436             }
437             return class_exists($className,false) || interface_exists($className,false);
438         }
439         return true;
Stack Trace #0     +   C:\xampp\htdocs\yii\framework\YiiBase.php(427): YiiBase::autoload() 
 #1       unknown(0): YiiBase::autoload("TbWidget") 
 #2     –  C:\xampp\htdocs\internetsite.com.ua\protected\extensions\bootstrap\widgets\TbNav.php(65): spl_autoload_call("TbWidget") 
60     /**
61      * Initializes the widget.
62      */
63     public function init()
64     {
65         $this->attachBehavior('TbWidget', new TbWidget);
66         $this->copyId();
67         $route = $this->controller->getRoute();
68         if ($this->stacked) {
69             TbHtml::addCssClass('nav-stacked', $this->htmlOptions);
70         }
 #3     +   C:\xampp\htdocs\yii\framework\web\CBaseController.php(147): TbNav->init() 
 #4     +   C:\xampp\htdocs\yii\framework\web\CBaseController.php(172): CBaseController->createWidget("bootstrap.widgets.TbNav", array("type" => "pills", "items" => array(1 => array("id" => "1", "parent_id" => "0", "label" => "Первое меню", "items" => array(2 => array("id" => "2", "parent_id" => "1", "label" => "Подменю для 1"))), 3 => array("id" => "3", "parent_id" => "0", "label" => "Меню2")))) 
 #5     –  C:\xampp\htdocs\internetsite.com.ua\protected\views\site\index.php(26): CBaseController->widget("bootstrap.widgets.TbNav", array("type" => "pills", "items" => array(1 => array("id" => "1", "parent_id" => "0", "label" => "Первое меню", "items" => array(2 => array("id" => "2", "parent_id" => "1", "label" => "Подменю для 1"))), 3 => array("id" => "3", "parent_id" => "0", "label" => "Меню2")))) 
21 
22     <?php 
23      $this->widget('bootstrap.widgets.TbNav', array(
24     'type' => TbHtml::NAV_TYPE_PILLS,
25     'items' => $menuha,
26     ));
27     ?>
 #6     +   C:\xampp\htdocs\yii\framework\web\CBaseController.php(126): require("C:\xampp\htdocs\internetsite.com.ua\protected\views\site\index.p...") 
 #7     +   C:\xampp\htdocs\yii\framework\web\CBaseController.php(95): CBaseController->renderInternal("C:\xampp\htdocs\internetsite.com.ua\protected\views\site\index.p...", array("menuha" => array(1 => array("id" => "1", "parent_id" => "0", "label" => "Первое меню", "items" => array(2 => array("id" => "2", "parent_id" => "1", "label" => "Подменю для 1"))), 3 => array("id" => "3", "parent_id" => "0", "label" => "Меню2"))), true) 
 #8     +   C:\xampp\htdocs\yii\framework\web\CController.php(869): CBaseController->renderFile("C:\xampp\htdocs\internetsite.com.ua\protected\views\site\index.p...", array("menuha" => array(1 => array("id" => "1", "parent_id" => "0", "label" => "Первое меню", "items" => array(2 => array("id" => "2", "parent_id" => "1", "label" => "Подменю для 1"))), 3 => array("id" => "3", "parent_id" => "0", "label" => "Меню2"))), true) 
 #9     +   C:\xampp\htdocs\yii\framework\web\CController.php(782): CController->renderPartial("index", array("menuha" => array(1 => array("id" => "1", "parent_id" => "0", "label" => "Первое меню", "items" => array(2 => array("id" => "2", "parent_id" => "1", "label" => "Подменю для 1"))), 3 => array("id" => "3", "parent_id" => "0", "label" => "Меню2"))), true) 
 #10     –  C:\xampp\htdocs\internetsite.com.ua\protected\controllers\SiteController.php(38): CController->render("index", array("menuha" => array(1 => array("id" => "1", "parent_id" => "0", "label" => "Первое меню", "items" => array(2 => array("id" => "2", "parent_id" => "1", "label" => "Подменю для 1"))), 3 => array("id" => "3", "parent_id" => "0", "label" => "Меню2")))) 
33         foreach ($result as $value){
34         $data[$value['id']]=array('id'=>$value['id'],'parent_id'=>$value['parent_id'],'label'=>$value['title']);
35         }
36     $dat = Menu::mapTree($data);
37         
38                 $this->render('index',array('menuha'=>$dat));
39     }
40 
41 
42 
43     /**
 #11     +   C:\xampp\htdocs\yii\framework\web\actions\CInlineAction.php(49): SiteController->actionIndex() 
 #12     +   C:\xampp\htdocs\yii\framework\web\CController.php(308): CInlineAction->runWithParams(array()) 
 #13     +   C:\xampp\htdocs\yii\framework\web\CController.php(286): CController->runAction(CInlineAction) 
 #14     +   C:\xampp\htdocs\yii\framework\web\CController.php(265): CController->runActionWithFilters(CInlineAction, array()) 
 #15     +   C:\xampp\htdocs\yii\framework\web\CWebApplication.php(282): CController->run("") 
 #16     +   C:\xampp\htdocs\yii\framework\web\CWebApplication.php(141): CWebApplication->runController("") 
 #17     +   C:\xampp\htdocs\yii\framework\base\CApplication.php(180): CWebApplication->processRequest() 
 #18     +   C:\xampp\htdocs\internetsite.com.ua\index.php(13): CApplication->run() 

 2014-03-18 14:10:45 Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 Yii Framework/1.1.14
Может беда в том что yii и сайт в соседних директориях? Где то-то подправить пути?

Вот мой main.php

Код: Выделить всё

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'My Web Application',
        'aliases' => array(
        'bootstrap' => realpath(__DIR__.'/../extensions/bootstrap'), 
    ),

    // preloading 'log' component
    'preload'=>array('log'),
    // autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
        'bootstrap.helpers.TbHtml',
    ),

    'modules'=>array(
        // uncomment the following to enable the Gii tool
        
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'generatorPaths' => array('bootstrap.gii'),
            'password'=>'123',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            // 'ipFilters'=>array('127.0.0.1','::1'),
            
        ),
        'adminka',
        
    ),

    // application components
    'components'=>array(
        'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
        ),
                'bootstrap' => array(
            'class' => 'bootstrap.components.TbApi',   
        ),
        // uncomment the following to enable URLs in path-format
        
        'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),
        ),
        
/*
        'db'=>array(
            'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
        ),
*/
        'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=internetsite',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ),
        // uncomment the following to use a MySQL database
        /*
        'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=testdrive',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ),
        */
        'errorHandler'=>array(
            // use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
        'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error, warning',
                ),
                // uncomment the following to show log messages on web pages
                /*
                array(
                    'class'=>'CWebLogRoute',
                ),
                */
            ),
        ),
    ),

    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params'=>array(
        // this is used in contact page
        'adminEmail'=>'[email protected]',
    ),
);
 
Вот код вызова виджета:

Код: Выделить всё

<?php $this->widget('bootstrap.widgets.TbNav', array(
    'type' => TbHtml::NAV_TYPE_PILLS,
    'items' => $menuha,
    )); ?>
Я явно болван, но где конкретно? Помогите плиз.

PS: работаю на локалхосте с помощью xampp
Аватара пользователя
yiijeka
Сообщения: 3103
Зарегистрирован: 2012.01.28, 09:14
Откуда: Беларусь
Контактная информация:

Re: Помогите с include(TbWidget.php): failed to open stream

Сообщение yiijeka »

дело в 'bootstrap' => realpath(__DIR__.'/../extensions/bootstrap'),
Аватара пользователя
wokster
Сообщения: 308
Зарегистрирован: 2013.09.06, 14:12
Контактная информация:

Re: Помогите с include(TbWidget.php): failed to open stream

Сообщение wokster »

Как его изменить что бы заработало.

framework
и
сайт
в соседних каталогах видимо в этом дело?
Аватара пользователя
wokster
Сообщения: 308
Зарегистрирован: 2013.09.06, 14:12
Контактная информация:

Re: Помогите с include(TbWidget.php): failed to open stream

Сообщение wokster »

Решил путем добавления

Код: Выделить всё

    'import'=>array(
        'application.models.*',
        'application.components.*',
        'bootstrap.helpers.TbHtml',
        'bootstrap.helpers.TbArray',
        'bootstrap.behaviors.TbWidget',

    ), 
m00n_lite
Сообщения: 10
Зарегистрирован: 2014.04.11, 20:50

Re: Помогите с include(TbWidget.php): failed to open stream

Сообщение m00n_lite »

https://github.com/Crisu83/yiistrap/issues/186
Crisu83
That is correct. Yiistrap is now path and alias independent because it uses Composer for autoloading. If you are not using Composer you need to import the classes manually like you did. I will update the readme asap. This also means that you do not need the "bootstrap" alias anymore and you can use the real path alias instead.

вот решение

Код: Выделить всё

'import'=>array(
    'application.models.*',
    'application.components.*',
    'bootstrap.helpers.TbHtml',
        'bootstrap.helpers.TbArray',
        'bootstrap.behaviors.TbWidget',
        'bootstrap.widgets.*'
    ),
Ответить