2、由于验证此缓存标识是否存在的规则,会用于大量的 API 中。最张决定自定义验证规则,以复用此验证规则。
3、由于是在模块中编写验证规则。module:make-rule Create a new validation rule for the specified module.
<pre class="wp-block-syntaxhighlighter-code">
PS E:\wwwroot\object> php artisan help module:make-rule
Description:
Create a new validation rule for the specified module.
Usage:
module:make-rule <name> [<module>]
Arguments:
name The name of the rule class.
module The name of module will be used.
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
PS E:\wwwroot\object> php artisan module:make-rule ThemeEditor/ThemeEditorCodeExistsRule ThemeStore
Created : E:/wwwroot/object/Modules/ThemeStore/Rules/ThemeEditor/ThemeEditorCodeExistsRule.php
PS E:\wwwroot\object>
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<!-- /resources/views/alert.blade.php -->
<div class="alert alert-danger">
<div class="alert-title">Forbidden</div>
You are not allowed to access this resource!
</div>
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<?php
namespace Modules\ThemeStore\Tests\Functional\GraphQl;
use Nuwave\Lighthouse\Testing\MakesGraphQLRequests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Nuwave\Lighthouse\Testing\ClearsSchemaCache;
use Tests\CreatesApplication;
class ThemeAssetGraphQlApiTest extends BaseTestCase
{
use CreatesApplication,
ClearsSchemaCache,
MakesGraphQLRequests;
protected function setUp(): void
{
parent::setUp();
$this->bootClearsSchemaCache();
}
}
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<?php
namespace Modules\ThemeStore\Tests\Functional\GraphQl;
use Nuwave\Lighthouse\Testing\MakesGraphQLRequests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Nuwave\Lighthouse\Testing\RefreshesSchemaCache;
use Tests\CreatesApplication;
class ThemeAssetGraphQlApiTest extends BaseTestCase
{
use CreatesApplication,
ClearsSchemaCache,
MakesGraphQLRequests;
protected function setUp(): void
{
parent::setUp();
$this->bootRefreshesSchemaCache();
}
}
</pre>
5、运行测试,测试通过。如图3
图3
PS E:\wwwroot\object> .\vendor\bin\phpunit --process-isolation .\Modules\ThemeStore\Tests\Functional\GraphQl\ThemeAssetGraphQlApiTest.php
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
... 3 / 3 (100%)
Time: 7.73 seconds, Memory: 16.00 MB
OK (3 tests, 11 assertions)
PS E:\wwwroot\object>
3、再次执行时,提示:Key conedevelopment/blade-filters is a duplicate in ./composer.json at line 91。Warning: The lock file is not up to date with the latest changes in composer.json。如图2
图2
<pre class="wp-block-syntaxhighlighter-code">
PS E:\wwwroot\object> composer install
Key conedevelopment/blade-filters is a duplicate in ./composer.json at line 91
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Nothing to install, update or remove
</pre>
PS E:\wwwroot\object> composer update conedevelopment/blade-filters
Key conedevelopment/blade-filters is a duplicate in ./composer.json at line 91
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 23 installs, 0 updates, 1 removal
- Removing neobject/facebook-conversions-api (1.4.0)
- Locking barryvdh/laravel-debugbar (v3.6.7)
- Locking conedevelopment/blade-filters (v0.8.0)
- Locking elasticsearch/elasticsearch (8.x-dev 3cab97a)
- Locking ezimuel/guzzlestreams (3.0.1)
- Locking ezimuel/ringphp (1.2.0)
- Locking haydenpierce/class-finder (0.4.3)
- Locking laragraph/utils (v1.3.0)
- Locking laravel/scout (v8.6.1)
- Locking laravie/html (v6.0.1)
- Locking lstrojny/functional-php (1.17.0)
- Locking maximebf/debugbar (v1.18.0)
- Locking nuwave/lighthouse (v5.45.0)
- Locking orchestra/asset (v4.0.1)
- Locking orchestra/contracts (v4.1.1)
- Locking orchestra/support (v4.1.1)
- Locking react/promise (v2.9.0)
- Locking respect/stringifier (0.2.0)
- Locking respect/validation (2.2.3)
- Locking spatie/valuestore (1.3.0)
- Locking statamic/stringy (3.1.2)
- Locking tamayo/laravel-scout-elastic (8.0.3)
- Locking thecodingmachine/safe (v1.3.3)
- Locking webonyx/graphql-php (v14.11.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 23 installs, 0 updates, 1 removal
- Downloading conedevelopment/blade-filters (v0.8.0)
- Downloading elasticsearch/elasticsearch (8.x-dev 3cab97a)
- Downloading lstrojny/functional-php (1.17.0)
- Downloading nuwave/lighthouse (v5.45.0)
- Downloading statamic/stringy (3.1.2)
- Downloading orchestra/contracts (v4.1.1)
- Downloading orchestra/support (v4.1.1)
- Downloading laravie/html (v6.0.1)
- Downloading orchestra/asset (v4.0.1)
- Downloading spatie/valuestore (1.3.0)
- Removing neobject/facebook-conversions-api (1.4.0)
- Installing maximebf/debugbar (v1.18.0): Extracting archive
- Installing barryvdh/laravel-debugbar (v3.6.7): Extracting archive
- Installing conedevelopment/blade-filters (v0.8.0): Extracting archive
- Installing react/promise (v2.9.0): Extracting archive
- Installing ezimuel/guzzlestreams (3.0.1): Extracting archive
- Installing ezimuel/ringphp (1.2.0): Extracting archive
- Installing elasticsearch/elasticsearch (8.x-dev 3cab97a): Extracting archive
- Installing lstrojny/functional-php (1.17.0): Extracting archive
- Installing webonyx/graphql-php (v14.11.5): Extracting archive
- Installing thecodingmachine/safe (v1.3.3): Extracting archive
- Installing laragraph/utils (v1.3.0): Extracting archive
- Installing haydenpierce/class-finder (0.4.3): Extracting archive
- Installing nuwave/lighthouse (v5.45.0): Extracting archive
- Installing statamic/stringy (3.1.2): Extracting archive
- Installing orchestra/contracts (v4.1.1): Extracting archive
- Installing orchestra/support (v4.1.1): Extracting archive
- Installing laravie/html (v6.0.1): Extracting archive
- Installing orchestra/asset (v4.0.1): Extracting archive
- Installing respect/stringifier (0.2.0): Extracting archive
- Installing respect/validation (2.2.3): Extracting archive
- Installing spatie/valuestore (1.3.0): Extracting archive
- Installing laravel/scout (v8.6.1): Extracting archive
- Installing tamayo/laravel-scout-elastic (8.0.3): Extracting archive
9 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Google\Task\Composer::cleanup
Class Sofa\Eloquence\Searchable\Searchable located in E:/wwwroot/object/vendor/sofa/eloquence-base/src\Contracts\Searchable\Searchable.php does not comply with psr-4 autoloading standard. Skipping.
Class Modules\ThemeStore\Tests\FactoryTest located in E:/wwwroot/object/Modules\ThemeStore\Tests\Unit\FactoryTest.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: arubacao/asset-cdn
Discovered Package: axlon/laravel-postal-code-validation
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: beyondcode/laravel-er-diagram-generator
Discovered Package: boaideas/laravel-cli-create-user
Discovered Package: conedevelopment/blade-filters
Discovered Package: cviebrock/eloquent-sluggable
Discovered Package: dingo/api
Discovered Package: fideloper/proxy
Discovered Package: genealabs/laravel-model-caching
Discovered Package: igaster/laravel-theme
Discovered Package: ignited/laravel-omnipay
Discovered Package: intervention/image
Discovered Package: jenssegers/agent
Discovered Package: jgrossi/corcel
Discovered Package: laravel/passport
Discovered Package: laravel/scout
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: maatwebsite/excel
Discovered Package: mavinoo/laravel-batch
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nuwave/lighthouse
Discovered Package: nwidart/laravel-modules
Discovered Package: orangehill/iseed
Discovered Package: overtrue/laravel-pinyin
Discovered Package: overtrue/laravel-wechat
Discovered Package: prettus/l5-repository
Discovered Package: s-ichikawa/laravel-sendgrid-driver
Discovered Package: sentry/sentry-laravel
Discovered Package: silber/page-cache
Discovered Package: socialiteproviders/manager
Discovered Package: sofa/eloquence-base
Discovered Package: sofa/eloquence-mutable
Discovered Package: spatie/laravel-activitylog
Discovered Package: spatie/laravel-permission
Discovered Package: spatie/laravel-query-builder
Discovered Package: spatie/laravel-sitemap
Discovered Package: tamayo/laravel-scout-elastic
Discovered Package: torann/geoip
Package manifest generated successfully.
115 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
5、再次执行 composer install 时,不再报错。
PS E:\wwwroot\object> composer install
Key conedevelopment/blade-filters is a duplicate in ./composer.json at line 91
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Google\Task\Composer::cleanup
Class Sofa\Eloquence\Searchable\Searchable located in E:/wwwroot/object/vendor/sofa/eloquence-base/src\Contracts\Searchable\Searchable.php does not comply with psr-4 autoloading standard. Skipping.
Class Modules\ThemeStore\Tests\FactoryTest located in E:/wwwroot/object/Modules\ThemeStore\Tests\Unit\FactoryTest.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: arubacao/asset-cdn
Discovered Package: axlon/laravel-postal-code-validation
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: beyondcode/laravel-er-diagram-generator
Discovered Package: boaideas/laravel-cli-create-user
Discovered Package: conedevelopment/blade-filters
Discovered Package: cviebrock/eloquent-sluggable
Discovered Package: dingo/api
Discovered Package: fideloper/proxy
Discovered Package: genealabs/laravel-model-caching
Discovered Package: igaster/laravel-theme
Discovered Package: ignited/laravel-omnipay
Discovered Package: intervention/image
Discovered Package: jenssegers/agent
Discovered Package: jgrossi/corcel
Discovered Package: laravel/passport
Discovered Package: laravel/scout
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: maatwebsite/excel
Discovered Package: mavinoo/laravel-batch
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nuwave/lighthouse
Discovered Package: nwidart/laravel-modules
Discovered Package: orangehill/iseed
Discovered Package: overtrue/laravel-pinyin
Discovered Package: overtrue/laravel-wechat
Discovered Package: prettus/l5-repository
Discovered Package: s-ichikawa/laravel-sendgrid-driver
Discovered Package: sentry/sentry-laravel
Discovered Package: silber/page-cache
Discovered Package: socialiteproviders/manager
Discovered Package: sofa/eloquence-base
Discovered Package: sofa/eloquence-mutable
Discovered Package: spatie/laravel-activitylog
Discovered Package: spatie/laravel-permission
Discovered Package: spatie/laravel-query-builder
Discovered Package: spatie/laravel-sitemap
Discovered Package: tamayo/laravel-scout-elastic
Discovered Package: torann/geoip
Package manifest generated successfully.
115 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
1、执行命令:npm run build 时,提示:npm ERR! Missing script: “build”。如图1
图1
PS E:\wwwroot\object> npm run build
npm ERR! Missing script: "build"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Lenovo\AppData\Local\npm-cache\_logs\2022-04-15T01_30_16_068Z-debug.log
3、根据提示:To see a list of scripts, run: npm run。要查看脚本列表,请运行 npm run。支持:npm run dev、npm run prod。如图3
图3
PS E:\wwwroot\object> npm run
Lifecycle scripts included in undefined:
test
jest
available via `npm run-script`:
dev
npm run development
development
mix
watch
mix watch
watch-poll
mix watch -- --watch-options-poll=1000
hot
mix watch --hot
production
mix --production
prod
npm run production
gh-pages
gh-pages -d public/docs -r https://github.com/pheye/wdocs.git
analyzer
NODE_ENV=production npm_config_report=true npm run prod
4、执行 npm run dev ,运行成功。如图4
图4
PS E:\wwwroot\object> npm run dev
> dev
> npm run development
> development
> mix
● Mix █████████████████████████ emitting (98%)
after emit
Laravel Mix v6.0.39
✔ Compiled Successfully in 127974ms