yiisoft / yii2

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

sourcePath in DebugAsset #3542

Closed arturf closed 10 years ago

arturf commented 10 years ago

sourcePath default value in DebugAsset is @yii/debug/assets, but when installing framework wia composer like this:

"require": {
        "yiisoft/yii2": "2.0.0-beta",
        "yiisoft/yii2-composer": "2.0.0-beta",
        "yiisoft/yii2-debug": "2.0.0-beta",
        "yiisoft/yii2-bootstrap": "2.0.0-beta"
    },

vendor/yiisoft/yii2 does not contain debug extension so we have an error The file or directory to be published does not exist: /home/.../vendor/yiisoft/yii2/debug/assets.

Maybe make sense set sourcePath to '@vendor/yiisoft/yii2-debug/assets' by default like in BootstrapAsset?

samdark commented 10 years ago

When installed yiisoft/yii2-debug should define @yii/debug alias in vendor/yiisoft/extensions.php so framework is able to recognize it.

What's inside your extensions.php, what's in your composer.json, which command was used to install packages?

arturf commented 10 years ago

extensions.php

$vendorDir = dirname(__DIR__);

return array (
  'yiisoft/yii2-bootstrap' => 
  array (
    'name' => 'yiisoft/yii2-bootstrap',
    'version' => '2.0.0.0-beta',
    'alias' => 
    array (
      '@yii/bootstrap' => $vendorDir . '/yiisoft/yii2-bootstrap',
    ),
  ),
  'yiisoft/yii2-debug' => 
  array (
    'name' => 'yiisoft/yii2-debug',
    'version' => '2.0.0.0-beta',
    'alias' => 
    array (
      '@yii/debug' => $vendorDir . '/yiisoft/yii2-debug',
    ),
  ),
);

my composer.json

{
    "name": "binn/erp",
    "description": "",
    "authors": [],
    "require": {
        "php":">=5.4.0",
        "yiisoft/yii2": "2.0.0-beta",
        "yiisoft/yii2-composer": "2.0.0-beta",
        "yiisoft/yii2-debug": "2.0.0-beta",
        "yiisoft/yii2-bootstrap": "2.0.0-beta",
        "binn/sbuilder": "dev-master"
    },
    "repositories": [
        {
            "type": "git",
            "url": "git@git.devlabs.me:base/yii_cmf.git"
        }
    ]
}

Command for install - composer.phar install

Later (when added debug extension dependency into composer) - composer.phar update

And when I added Yii::setAlias('@yii/debug', Yii::getAlias('@vendor/yiisoft/yii2')) to main config file debug start works, but markup is broken - http://joxi.ru/cMt9UxjKTJASTqEEED8

samdark commented 10 years ago

extensions.php seems to be generated correctly. Need to reproduce it.

cebe commented 10 years ago

@arturf do you have the following line in your application config?

https://github.com/yiisoft/yii2/blob/master/apps/basic/config/web.php#L9

arturf commented 10 years ago

@cebe no.. my mistake, thanks.

But what about to automatically include this config on framework core? Also with mapping with custom user config?

samdark commented 10 years ago

@arturf it's included by default in both basic and advanced application configs. Probably worth moving it from configs to the application code. @yiisoft/core-developers what do you think?

cebe commented 10 years ago

when @vendor is set we could easily use it to determine location of extension. Worth setting a default value to @vendor/yiisoft/extensions.php for it.

qiangxue commented 10 years ago

Sounds good to me.

samdark commented 10 years ago

I'll handle it.

samdark commented 10 years ago

Done.

arturf commented 10 years ago

@samdark great, thanks )