luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
812 stars 207 forks source link

Console theme/create report error #2152

Closed helprepair closed 2 years ago

helprepair commented 2 years ago

What steps will reproduce the problem?

php luya theme/create

What is the expected result?

developer@WCZ-PC MINGW64 /d/app/day01/example0001/1.1.8 $ php luya theme/create Enter the name (lower case) of the theme you like to generate: basic Enter the theme location where to generate (as path alias e.g. app, ): [app] Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @app\themes\basic'

in D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\BaseYii.php:154

Stack trace:

0 D:\app\day01\example0001\1.1.8\vendor\luyadev\luya-core\console\commands\ThemeController.php(63): yii\BaseYii::getAlias('@ap

p\themes\bas...') luyadev/luya-kickstarter-bootstrap4#1 [internal function]: luya\console\commands\ThemeController->actionCreate('basic') luyadev/luya-kickstarter-bootstrap4#2 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array) luyadev/luya-kickstarter-bootstrap4#3 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\base\Controller.php(178): yii\base\InlineAction->runWithParams(Array) luyadev/luya-kickstarter-bootstrap4#4 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\console\Controller.php(182): yii\base\Controller->runAction('create', Arr ay) luyadev/luya-kickstarter-bootstrap4#5 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\base\Module.php(552): yii\console\Controller->runAction('create', Array) luyadev/luya-kickstarter-bootstrap4#6 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('theme/create', Array) luyadev/luya-kickstarter-bootstrap4#7 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('theme/c reate', Array) luyadev/luya-module-cms#189 D:\app\day01\example0001\1.1.8\vendor\yiisoft\yii2\base\Application.php(384): yii\console\Application->handleRequest(Object( yii\console\Request)) luyadev/luya-kickstarter-bootstrap4#9 D:\app\day01\example0001\1.1.8\vendor\luyadev\luya-core\base\Boot.php(238): yii\base\Application->run() luyadev/luya-kickstarter-bootstrap4#10 D:\app\day01\example0001\1.1.8\vendor\luyadev\luya-core\bin\luya(36): luya\base\Boot->applicationConsole() luyadev/luya-kickstarter-bootstrap4#11 {main}

What do you get instead? (A Screenshot can help us a lot!)

图片

LUYA Check ouput (run this script and post the result: luyacheck.php)

Additional infos

Q A
LUYA Version 1.1.8
PHP Version 7.4.28
Platform WNMP
Operating system Windows 10
nadar commented 2 years ago

@boehsermoe maybe you know something regarding this?

helprepair commented 2 years ago

luyadev\luya-core\console\commands\ThemeController.php

        // $basePath = $themeLocation . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $themeName;
        $basePath = $themeLocation . '/' . 'themes' . '/' . $themeName; // fix
        $themeFolder = Yii::getAlias($basePath);

After I make this modification, I can create it successfully.

nadar commented 2 years ago

so the DIRECTORY_SEPARATOR was the problem?

nadar commented 2 years ago

But you mentioned you are on windows, so it should be \ not /. But i think its because Yii::getAlias throws an exception here: https://github.com/yiisoft/yii2/blob/master/framework/BaseYii.php#L154

@helprepair could you provide me the value of $themeLocation and $basePath before and after running Yii::getAlias?

Update: From the exception it seems to be @app\themes\basic' before running trough getAlias

helprepair commented 2 years ago
$ php luya theme/create
Enter the name (lower case) of the theme you like to generate: basic
Enter the theme location where to generate (as path alias e.g. app, ): [app]
string(20) "$themeLocation :@app"
string(22) "DIRECTORY_SEPARATOR :\"
string(28) "$basePath :@app\themes\basic"