假如你的项目要分离模块,比如说admin、shop、blog等等,你可能需要这个插件
详细文档:
https://nwidart.com/laravel-modules/.
https://packagist.org/packages/nwidart/laravel-modules

Laravel laravel-modules
5.4 ^1.0
5.5 ^2.0
5.6 ^3.0
5.7 ^4.0
5.8 ^5.0

安装

#install
composer require nwidart/laravel-modules
#
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
#在composer添加"Modules\\": "Modules/"
{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Modules\\": "Modules/"
    }
  }
}
#运行
composer dump-autoload

注意事项

#lang
Lang::get('blog::group.name');
@trans('blog::group.name');
#view
view('blog::index')
view('blog::partials.sidebar')
#config
Config::get('blog.name')

命令

#创建模块
php artisan module:make Blog

目录结构

app/
bootstrap/
vendor/
Modules/
  ├── Blog/
      ├── Assets/
      ├── Config/
      ├── Console/
      ├── Database/
          ├── Migrations/
          ├── Seeders/
      ├── Entities/
      ├── Http/
          ├── Controllers/
          ├── Middleware/
          ├── Requests/
      ├── Providers/
          ├── BlogServiceProvider.php
          ├── RouteServiceProvider.php
      ├── Resources/
          ├── assets/
              ├── js/
                ├── app.js
              ├── sass/
                ├── app.scss
          ├── lang/
          ├── views/
      ├── Routes/
          ├── api.php
          ├── web.php
      ├── Repositories/
      ├── Tests/
      ├── composer.json
      ├── module.json
      ├── package.json
      ├── webpack.mix.js

php使用生成器读取超大文件

<?php function getLines($file) { $f = fopen($file, 'r'); try { while ($line = fgets($f)) { yield $line; ...

阅读全文

php获取字符串里面的图片,xpath方式

代码 <?php $html = <<<str <html> <head> <title>123</title> </head> <body> <img src=&quo...

阅读全文

Thinkphp5 in查询结果按照in里面的顺序排

或许有人会注意过,但我以前真不知道 SQL: select * from table where id IN (3,6,9,1,2,5,8,7); 这样的情况取出来后,其实,id还是按1,2,3,4,5,6,7,8,9,排序...

阅读全文

欢迎留言