yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Assets Broken with pull yesterday #1202

Closed notsoluckycharm closed 10 years ago

notsoluckycharm commented 10 years ago

Using the advanced example is now broken due to something that has happened with 'yii\bootstrap*'. If you run the example I am getting the following:

Fatal Error – yii\base\ErrorException Class 'yii\bootstrap\BootstrapAsset' not found

I try to remove it from the app/backend/assets/AppAsset.php so that my config looks like the following:

use yii\web\AssetBundle;

/**
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class AppAsset extends AssetBundle
{
    public $sourcePath = '@app/assets';
    //public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = ['css/site.css'];
    public $js = [];
    public $depends = [
        'yii\web\YiiAsset',
        //'yii\bootstrap\BootstrapAsset',
    ];
}

I then recieve the following error:

Fatal Error – yii\base\ErrorException

Class 'yii\bootstrap\NavBar' not found

  1. in /home/brad/bgunn.com/app/views/layouts/main.php at line 33 2829303132333435363738 <?php $this->head(); ?> beginBody(); ?> 'Brad Gunn', 'brandUrl' => Yii::$app->homeUrl, 'options' => [ 'class' => 'navbar-inverse navbar-fixed-top', ],
  2. yii\base\Application::handleFatalError()

I only mildly customized the advanced app, this should be easily reproducible by loading the clean advanced app.

What else can I give you to help out ? Seems something broke with the yii\bootstrap namespace.

qiangxue commented 10 years ago

Does your app config contain this line?

    'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
notsoluckycharm commented 10 years ago

Yes, It's also worth mentioning I am using the composer yii2 repository as well, though this does not answer your question.

Excerpt from my main.php:

'id' => 'app-backend', 'basePath' => dirname(DIR), 'vendorPath' => dirname(dirname(DIR)) . '/vendor', 'preload' => ['log'], 'controllerNamespace' => 'controllers', 'modules' => [], 'extensions' => require(DIR . '/../../vendor/yii-extensions.php'), 'components' => [ 'request' => [ 'enableCsrfValidation' => true, ],

On Thu, Nov 14, 2013 at 12:48 PM, Qiang Xue notifications@github.comwrote:

Does your app config contain this line?

'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),

— Reply to this email directly or view it on GitHubhttps://github.com/yiisoft/yii2/issues/1202#issuecomment-28505917 .

qiangxue commented 10 years ago

'extensions' =>require(__DIR__ . '/../../vendor/yii-extensions.php')? It should be .../vendor/yiisoft/extensions.php

notsoluckycharm commented 10 years ago

I noticed your line has /../ and my line has /../../

I took your line and received the following 500 message in my nginx log.

PHP message: PHP Fatal error: require(): Failed opening required '/home/brad/bgunn.com/app/config/../vendor/yii-extensions.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/brad/ bgunn.com/app/config/main.php on line 19" while reading response header from upstream, client: 24.103.114.217, server: bgunn.com, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm/php5-fpm.sock:", host: "bgunn.com"

I do indeed have this directory structure by the way that should be compatible with the configuration files.

bgunn.com// is root

//app/ -- app root //vendor/yii-extensions.php -- composer loaded vendor root //www/index.php -- web root

Perhaps it's simply broken via composer loading? I do not have a vendor directory within my application code directory.

On Thu, Nov 14, 2013 at 12:52 PM, Brad Gunn hevean@gmail.com wrote:

Yes, It's also worth mentioning I am using the composer yii2 repository as well, though this does not answer your question.

Excerpt from my main.php:

'id' => 'app-backend', 'basePath' => dirname(DIR), 'vendorPath' => dirname(dirname(DIR)) . '/vendor', 'preload' => ['log'], 'controllerNamespace' => 'controllers', 'modules' => [], 'extensions' => require(DIR . '/../../vendor/yii-extensions.php'), 'components' => [ 'request' => [ 'enableCsrfValidation' => true, ],

On Thu, Nov 14, 2013 at 12:48 PM, Qiang Xue notifications@github.comwrote:

Does your app config contain this line?

'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),

— Reply to this email directly or view it on GitHubhttps://github.com/yiisoft/yii2/issues/1202#issuecomment-28505917 .

qiangxue commented 10 years ago

I was quoting your code. It's incorrect. You should fix it to be something like vendor/yiisoft/extensions.php.

notsoluckycharm commented 10 years ago

Well, I'll try to fix this on my own. But I'm telling you what worked yesterday for me no longer works today for me.

I'll update you when I find the solution, by the way, this is the contents of my yii-extensions.php

<?php return [];

I'm trying to locate if this is correct.

qiangxue commented 10 years ago

yii-extensions.php is no longer used (this change was introduced about two weeks ago). As I said, you just need to change to use yiisoft/extensions.php. There's nothing more you need to do.

notsoluckycharm commented 10 years ago

You are absolutely correct. I am sorry for not paying close enough attention to the small differences in the file system paths. I dismissed it because I am still having the same problem, though. Thank you for your patience.

"Class 'yii\bootstrap\BootstrapAsset' not found"

I'll figure it out :]

my config does say this now:

'extensions' => require(DIR . '/../../vendor/yiisoft/extensions.php'),

Things might have changed in the layouts/main.php that I'll take a look at.

qiangxue commented 10 years ago

If you still have the problem, check the content in extensions.php to see if it contains an entry for bootstrap. If not, you may try to remove bootstrap from your composer.json, composer update, then put back bootstrap to composer.json and update again.

notsoluckycharm commented 10 years ago

A lot has changed since I first started playing with Yii2.

My resolution ( for those who may land here from Google ):

Make sure you change your configuration and these extensions have moved to Composer, instead of possibly being baked into Yii2 itself.

Composer:

    "require": {
        "php": ">=5.3.0",
        "yiisoft/yii2": "dev-master",
        "yiisoft/yii2-swiftmailer": "dev-master",
        "yiisoft/yii2-bootstrap": "dev-master",
        "yiisoft/yii2-debug": "dev-master",
        "yiisoft/yii2-gii": "dev-master",

Thanks again for your patience qiangxue! Let me know if you need any assistance on coding Yii2. Thanks!