aatifbangash / contact
这将向管理员发送电子邮件并将联系查询保存在数据库中
0.0.4
2024-02-24 05:12 UTC
This package is auto-updated.
Last update: 2024-09-24 06:35:22 UTC
README
我们可以创建一个包含常见文件(模型、控制器、迁移、中间件等)的包,并将其作为composer包包含在所有微服务中。
这将向管理员发送电子邮件并将联系查询保存在数据库中
如何在我们的项目中使用它(微服务)
将以下块添加到您的composer.json文件中
"repositories": [ { "type": "vcs", "url": "https://github.com/aatifbangash/laravel-custom-package.git" //URL of your github repo } ], "require": { "bitfumes/contact": "dev-master" //your vendor/package_name (we can get the name from composer.json file from package) and repo branch with dev- prefix }
打开终端并安装/更新包。每次我们对包源代码进行更改时,都必须运行以下命令
composer update bitfumes/contact
composer dump-autoload
在浏览器中打开包的路由。您将看到输出
自定义包中的中间件
此外,我还在包中编写了一个中间件(MyMiddleware.php)。我们可以使用任何路由来使用它。
Route::get('/users', function () { // logic here... })->middleware('MyMiddleware'); //You don't need to register the MyMiddleware in the Kernal.php. It will auto-registered by the Laravel
对于私有仓库
如果您的仓库是私有的,则可以生成GitHub令牌并将其添加到您的composer全局配置中
composer config --global github-oauth.github.com YOUR_ACCESS_TOKEN
或者
生成ssh_key并将其添加到您的GitHub账户中
上传到Packagist
您必须通过GitHub凭据登录packagist.com。并将您的GitHub仓库URL提交给Packagist。同时,确保在将代码推送到仓库时创建带有标签(版本0.0.1)的发布
git tag -a v2.1.0 -m "在此标签中发布了xyz功能。"
git push --tags
添加到项目中
"require": { "aatifbangash/contact": "*" }
使用 * 添加版本控制。因此,每次我们运行 composer update aatifbangash/contact 来更改代码并将代码推送到仓库后,项目中的包都将更新为最新代码。
更新到特定版本
或者运行以下命令 composer require aatifbangash/contact:0.0.3 并指定标签号,以将包升级到项目中的特定版本。