cauriland / foundation
Laravel的用户界面框架。由TailwindCSS提供支持。
Requires
- php: ^8.0
- alexbarnsley/php-html-parser: ^3.2
- calebporzio/sushi: ^2.4
- danharrin/livewire-rate-limiting: ^0.3
- elgigi/commonmark-emoji: ^2.0
- ergebnis/phpstan-rules: ^1.0
- fakerphp/faker: ^1.16
- friendsofphp/php-cs-fixer: ^3.3
- google/recaptcha: ^1.2
- graham-campbell/analyzer: ^3.0
- guzzlehttp/guzzle: ^7.4
- illuminate/bus: ^8.73
- illuminate/contracts: ^8.73
- illuminate/http: ^8.73
- illuminate/mail: ^8.73
- illuminate/support: ^8.73
- illuminate/view: ^8.73
- jasonmccreary/laravel-test-assertions: ^2.0
- jenssegers/agent: ^2.6
- johnkary/phpunit-speedtrap: ^4.0
- laravel/fortify: ^1.8
- league/commonmark: ^2.0
- livewire/livewire: ^2.8
- mockery/mockery: ^1.4
- nunomaduro/collision: ^5.10
- nunomaduro/larastan: ^1.0
- nunomaduro/laravel-mojito: ^0.2
- orchestra/testbench: ^6.23
- pestphp/pest: ^1.21
- pestphp/pest-plugin-faker: ^1.0
- pestphp/pest-plugin-laravel: ^1.1
- pestphp/pest-plugin-livewire: ^1.0
- pestphp/pest-plugin-parallel: ^1.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.2
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: ^9.5
- pragmarx/google2fa-laravel: ^2.0
- rector/rector: ^0.12.19
- ruafozy/mersenne-twister: ^1.3
- savvot/random: ^0.3
- spatie/laravel-flash: ^1.8
- spatie/laravel-honeypot: ^4.0
- spatie/laravel-medialibrary: ^9.9
- spatie/laravel-newsletter: ^4.10
- spatie/laravel-package-tools: ^1.9
- spatie/laravel-personal-data-export: ^3.0
- spatie/laravel-schemaless-attributes: ^2.1
- spatie/pest-plugin-snapshots: ^1.1
- spatie/regex: ^3.1
- spatie/yaml-front-matter: ^2.0
- teamtnt/laravel-scout-tntsearch-driver: ^11.5
Requires (Dev)
- laravel/nova: ^3.30
- spatie/laravel-permission: ^3.16
- vyuldashev/nova-permission: ^3.0
Suggests
- laravel/nova: Needed for backend management of data
- spatie/laravel-permission: Needed for nova permissions & roles
- vyuldashev/nova-permission: Needed for nova permissions & roles
README
Laravel的框架。由TailwindCSS和Livewire提供支持。
先决条件
由于此包依赖于几个第三方包,您需要在项目中安装和配置以下内容
安装
使用composer要求:composer require cauriland/foundation
用法
示例
Composer脚本
将这些脚本添加到 composer.json
"scripts": [ "analyse": [ "vendor/bin/phpstan analyse --configuration=vendor/cauriland/foundation/phpstan.neon --memory-limit=2G" ], "format": [ "vendor/bin/php-cs-fixer fix --config=vendor/cauriland/foundation/.php-cs-fixer.php" ], "refactor": [ "./vendor/bin/rector process --config=vendor/cauriland/foundation/rector.php" ], "test": [ "./vendor/bin/pest" ], "test:fast": [ "./vendor/bin/pest --parallel" ], "test:coverage": [ "./vendor/bin/pest --coverage --min=100 --coverage-html=.coverage --coverage-clover=coverage.xml" ] ],
本地开发组件
此包包含大量前端组件,但本身不包含前端视图。因此,当您需要工作在此包上时,您需要依赖另一个项目的前端。通常,这可以通过将composer符号链接此包来完成,但在此情况下,还需要进行第二个步骤,以确保您可以运行 yarn watch
、yarn prod
等。
我将详细说明,并以marketplace.io项目为例。假设marketplace.io和laravel-foundation git仓库都已安装在我们的本地开发机器上的/Users/my-user/projects/
文件夹中。
步骤1 - Composer符号链接
在marketplace.io的composer.json
文件中,“repositories”部分添加laravel-foundation路径
"repositories": [ { "type": "path", "url": "../laravel-foundation" } ]
After that run composer require cauriland/foundation --ignore-platform-reqs -W
. The laravel-foundation package is now symlinked and you can work in your IDE from within your laravel-foundation
repo.
步骤2 - 符号链接node_modules
如果您在marketplace.io仓库中运行yarn watch
,您将遇到大量错误,因为依赖项不足以知道它们在符号链接的目录中。
- 删除
laravel-foundation
上的node_modules
目录。 - 通过运行
ln -s /Users/my-user/projects/marketsquare.io/node_modules node_modules
(在laravel-foundation仓库内部)将marketplace.io的node_modules
目录符号链接到laravel-foundation。
现在,当您回到marketplace.io仓库时,您可以运行yarn watch
。
完成后,别忘了取消符号链接。
将这些步骤转换为脚本
请注意:
这些脚本是为Mac用户编写的。如果您使用其他操作系统,您可能需要相应地进行调整。
unlink:foundation
使用git
命令恢复当前项目。
为了提高您的开发流程,您可以将这些步骤转换为脚本,并在命令行中直接使用它们,例如
$ link:foundation $ unlink:foundation
您可以将它们复制/粘贴到您的.bashrc
、.aliases
或您设置的任何用于管理别名文件中。
在深入研究代码之前,让我解释一下您可以如何使用它们(跳到代码)。
对于这些示例,我们使用marketplace.io
和laravel-foundation
仓库,假设它们都安装在我们的本地开发机器上的同一文件夹中(/Users/my-user/projects
)。
将当前项目符号链接到laravel-foundation
# move into marketsquare.io folder $ cd /Users/my-user/projects/marketsquare.io # symlink to laravel-foundation repo $ link:foundation
就这样!
该脚本自动尝试猜测laravel-foundation
仓库的位置,并将当前项目符号链接到它(在这种情况下为marketplace.io
)。
如果当前项目和laravel-foundation
仓库不在同一文件夹中,脚本将尝试回退一级(../../
)并再次尝试。如果找不到laravel-foundation
,脚本将退出并输出错误消息。
您始终可以通过传递参数来指定自定义路径
$ link:foundation 'Users/john/repos/laravel-foundation'
从您当前的项目中删除符号链接
# move into marketsquare.io folder $ cd /Users/my-user/projects/marketsquare.io # remove symlink $ unlink:foundation
再说一遍,就这么简单!
脚本会查找 .symlink_foundation
临时文件(由 link:foundation
创建),该文件包含符号链接的路径。如果未找到,它会尝试猜测 laravel-foundation
仓库的位置,并从当前项目(在这种情况下为 marketsquare.io
)中删除符号链接。
如果当前项目和laravel-foundation
仓库不在同一文件夹中,脚本将尝试回退一级(../../
)并再次尝试。如果找不到laravel-foundation
,脚本将退出并输出错误消息。
您始终可以通过传递参数来指定自定义路径
$ unlink:foundation 'Users/john/repos/laravel-foundation'
代码
脚本本身就一目了然,并且每行都有注释哦。
function link:foundation() { # Check if already symlinked [ -f .symlink_foundation ] && { echo "already symlinked"; return; } # Get path from args or guess it if [ "$1" != "" ]; then FOUNDATION="$1" elif [ -d ../laravel-foundation ]; then FOUNDATION="../laravel-foundation" elif [ -d ../../laravel-foundation ]; then FOUNDATION="../../laravel-foundation" else echo "Unable to find `laravel-foundation`" return fi # Generate random string RANDOM_STRING=$(base64 /dev/urandom | tr -d '/+' | dd bs=6 count=1 2>/dev/null) # Set Composer repo composer config repositories.${RANDOM_STRING} '{"type": "path", "url": "'${FOUNDATION}'"}' # Require cauriland/foundation composer require cauriland/foundation --ignore-platform-reqs -W # Remove node_modules folder rm -rf ${FOUNDATION}/node_modules # Symlink to cauriland/foundation node_modules folder ln -s $(pwd)/node_modules ${FOUNDATION}/node_modules # Create .symlink_foundation temp file echo ${FOUNDATION} >> .symlink_foundation # Inform user that all went ok echo "${FOUNDATION} has been symlinked" } function unlink:foundation() { # Get path from .symlink_foundation file or from args or guess it if [ -f .symlink_foundation ]; then FOUNDATION=$(cat .symlink_foundation) elif [ "$1" != "" ]; then FOUNDATION="$1" elif [ -d ../laravel-foundation ]; then FOUNDATION="../laravel-foundation" elif [ -d ../../laravel-foundation ]; then FOUNDATION="../../laravel-foundation" else echo "Unable to find `laravel-foundation`" return fi # Remove symlink unlink ${FOUNDATION}/node_modules # Remove temp file rm -rf .symlink_foundation # Clean up repo git reset --hard git clean -df # Inform user that all went ok echo "${FOUNDATION} symlink has been removed" }