douruoshen1449 2015-05-20 08:23
浏览 189
已采纳

Lumen Micro Framework => php artisan key:generate

I'm trying out the PHP micro Framework Lumen (from Laravel).

One of my first steps was to look into the .env.example file and make a copy of it to have my .env file. There is a variable APP_KEY just like there is in Laravel. Now I tried out the simple command php artisan key:generate to get my new key But I ran into the following error message:

[InvalidArgumentException] There are no commands defined in the "key" namespace.

Does some one know how I can generate keys for Lumen?

Update with solution

So I found my favorite solution for this problem. On the command line (Linux) I run php -r "echo md5(uniqid()).\" \";" what gives me something like this 7142720170cef01171fd4af26ef17c93.

If you are going to use Lumen more often, you may want to create an alias in your .bashrc, which is located in your home directory /home/USERNAME. To do so, you can open the file with nano ~/.bashrc or vi ~/.bashrc and copy the following alias at the end of the file, alias phpkey='php -r "echo md5(uniqid()).\" \";"'. Now you can use the command phpkey which will give you a 32 character long random string :)

  • 写回答

12条回答 默认 最新

  • dtla92562 2015-05-20 08:51
    关注

    The Laravel command is fairly simple. It just generates a random 32 character long string. You can do the same in Lumen. Just temporarily add a route like this:

    $router->get('/key', function() {
        return str_random(32);
    });
    

    Then go to /key in your browser and copy paste the key into your .env file.
    Afterwards remove the route.

    Obviously you could also use some random string generator online. Like this one

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(11条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘