将 baum/baum 与 Lumen 一起使用

Posted

技术标签:

【中文标题】将 baum/baum 与 Lumen 一起使用【英文标题】:Using baum/baum with Lumen 【发布时间】:2016-07-14 01:07:15 【问题描述】:

我正在尝试让 baum/baum / etrepat/baumlaravel/lumen-framework 一起工作。

我已将"baum/baum": "~1.1" 添加到我的composer.json 并让baum 正确安装,但是当我尝试使用php artisan baum:install nace_categories -vvv 创建数据库迁移时,我收到以下错误消息:

Mareks-MacBook-Air:myDWH marekstopka$ php artisan baum:install nace_categories -vvv


  [ReflectionException]               
  Class path.database does not exist  


Exception trace:
 () at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/container/Container.php:738
 ReflectionClass->__construct() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/container/Container.php:738
 Illuminate\Container\Container->build() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/container/Container.php:633
 Illuminate\Container\Container->make() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/laravel/lumen-framework/src/Application.php:205
 Laravel\Lumen\Application->make() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/container/Container.php:1178
 Illuminate\Container\Container->offsetGet() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/baum/baum/src/Baum/Console/InstallCommand.php:111
 Baum\Console\InstallCommand->getMigrationsPath() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/baum/baum/src/Baum/Console/InstallCommand.php:88
 Baum\Console\InstallCommand->writeMigration() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/baum/baum/src/Baum/Console/InstallCommand.php:64
 Baum\Console\InstallCommand->fire() at n/a:n/a
 call_user_func_array() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/container/Container.php:507
 Illuminate\Container\Container->call() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/console/Command.php:169
 Illuminate\Console\Command->execute() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/illuminate/console/Command.php:155
 Illuminate\Console\Command->run() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/symfony/console/Application.php:791
 Symfony\Component\Console\Application->doRunCommand() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/symfony/console/Application.php:186
 Symfony\Component\Console\Application->doRun() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at /Users/marekstopka/prace/myBusinessSuite/myDWH/vendor/laravel/lumen-framework/src/Console/Kernel.php:69
 Laravel\Lumen\Console\Kernel->handle() at /Users/marekstopka/prace/myBusinessSuite/myDWH/artisan:35

Mareks-MacBook-Air:myDWH marekstopka$ 

我已经添加了

$app->withFacades();
$app->withEloquent();
$app->register(Baum\Providers\BaumServiceProvider::class);

进入我的 bootstrap/app.php 以启用 Facades 和 Eloquent 并注册 Baum Service Provider

我也做过composer updatecomposer dump-autoload

有人有使用 Baum 嵌套集树和 Lumen 框架的经验吗?

【问题讨论】:

【参考方案1】:

将以下行放入您的 bootstrap/app.php:

$app->instance('path.base', $app->path());
$app->instance('path.database', $app->databasePath());

见https://github.com/etrepat/baum/pull/217

【讨论】:

以上是关于将 baum/baum 与 Lumen 一起使用的主要内容,如果未能解决你的问题,请参考以下文章

如何将 Angular js 路由与 laravel/lumen 路由一起使用?

未定义的方法 Laravel\Lumen\Application::booted()

Lumen Passport (dustrio/lumen-passport) - 使登录变得可访问

Auth0 与 ReactJS 和 Lumen - 受众看起来像一个随机字符串

Lumen JWT 令牌随请求一起发送

使用 Gitlab 仪表板 - 如何将 grafonnet 与 jsonnet 一起使用以生成我可以与 Grafana 一起使用的 json 文件