laravel framework – practical development (directory structure, routing, controller, model, view)

1. Directory structure of laravel framework app: Application directory, saves controllers, models, etc. in the project bootstrap: Save files related to framework startup config: Configuration file directory database: database migration files and data filling files public: Application entry file index.php and front-end resource files (such as CSS, JavaScript, etc.) resources: stores view files, language packs […]

laravel8 uses tymon/jwt-auth to log in

1.Install jwt composer require tymon/jwt-auth 2.Configuration.env 3. Open config/app.php Add the following configurations to the providers array and aliases array respectively. Tymon\JWTAuth\Providers\LaravelServiceProvider::class, ‘JWTAuth’ => Tymon\JWTAuth\Facades\JWTAuth::class, ‘JWTFactory’ => Tymon\JWTAuth\Facades\JWTFactory::class, As shown in the picture: 4. Add jwt configuration file php artisan vendor:publish –provider=”Tymon\JWTAuth\Providers\LaravelServiceProvider” 5. Generate jwt key php artisan jwt:secret 6. Add jwt key to .env […]

Pitfalls of Laravel chunk and chunkById

When writing scheduled task scripts, the chunk and chunkById APIs are often used. 1. Preface The database engine is innodb. A brief description of the table structure, only the fields used in this article are listed. Field Type Comments id int(11) ID type int(11) Type mark_time int(10) Mark time (timestamp) The index also lists only […]

DingTalk robot message push composer extension laravel-dingbot

DingTalk robot message sending Introduction There are many systems within the enterprise that support the company’s core business processes, such as CRM systems, transaction systems, monitoring and alarm systems, etc. Through DingTalk’s custom robot, these system events can be synchronized to DingTalk’s chat group. laravel-dingbot is a Laravel extension for DingTalk robot message push. You […]

php laravel multiple file compression

Controller code Download controller: DownloadController <?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\ConfirmationUseModel; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use ZipArchive; class DownloadController extends Controller {<!– –> public function download(Request $request){<!– –> $loadname = $request->get(‘apply_sn’,date(‘Y-m-d’));//Get the number as the downloaded file name and the default date as the name $id = $request->get(‘id’,0); if($id){<!– –> //Find the file list […]

Laravel project deployment

laravelChinesewebsite:“Laravel10ChineseDocumentation”|LaravelChinaCommunity Preparation InstallthewslsubsysteminWindows,andtheninstallUbuntuintheMicrosoftstore(sothedevelopmentenvironmentisLinux) Codeeditor-Vscode ConnecttotheWindowsSubsystem-PluginWSL-VisualStudioMarketplace PluginsforPHPdevelopment PHPIntellephense LaravelBladeSnippets LaravelExtraIntellisense? LaravelModelSnippets LaravelSnippets CommonpluginsforVScode Makesurethelnmpintegratedenvironment(Nginx+Mysql+phpunderLinux)isinstalled TocheckwhethertheComposertoolisinstalled,pleaseenterinthecommandterminal:composer-V Projectdeployment Createprojectsite 1,startvariousservicesinlnmp 2,startcreatingaprojectsite Projectsite Result Checkwhetherthestoragepathoftheprojectiscreated[Youcanalsoenter:explorer.exe.first,andentertheexplorertoview,suchas:Figure2] 3,startcreatingalaravelproject 1,throughthecomposercommand,installthelaravelframework #Notethatthemy_laravelbelowistheprojectIwanttocreate,andyoucandefineityourself[the”9.0.*”attheendindicatestheversionoflaravel] composercreate-projectlaravel/laravelmy_laravel”9.0.*” result:Theerrorisreportedherebecausetherearefilesintheprojectfile,wecandeletethemdirectly. #Whenwedirectlygototherightbuttonofthemouse=”deleteorrm-rf/my_laravle/.user.ini,ithasnoeffect #Atthistime,usethefollowingcommandtodelete chattr-i/home/wwwroot/my_laravle/.user.ini rm-rf/home/wwwroot/my_laravle/.user.ini #Summarize: chattr-i/sitedirectory/.user.ini rm-rf/sitedirectory/.user.ini Reinstalltheprocessafteranerror Finalresults 4,runtheproject 1,convenientandsimple #Let’sentertheprojectfirst cdmy_laravle #Afterenteringtheproject,enterthefollowingcommand phpartisanserve Screenshotofresult: 5.Finally,inordertoensurethatthisisourownlaravelproject,let’sdoalittlepractice Accordingtothepicturebelow,modifythecodeintheeditorLet’srefreshthepagejustnow Summary Attentioneveryone,thereisanerrorabove,becauseItypedlaravelwrongly, Itypeditaslaravle,whichmeansel==》leattheend. (“‘3′”)

PHP (laravel+apache+SQLserver) configuration link SQLserver

1. Requirements: The laravel framework can connect to the SQLserver database 2. Environment: local service based on phpstudy under Windows laravel + apache + SQLserver Windows10 laravel5 + SQLserver2008/SQLserver2012 PHP7.3/PHP7.4 3. Required documents [Free] PHP (laravel + apache + SQLserver) configures the file resources required to link to SQLserver – CSDN Library Fourth, preparation 1. […]

Laravel queries the request multiple times, and the next request clears the where condition of the last request

In Laravel, you can use the `where` method to add query conditions, but every time you add a `where` condition, these conditions are persisted in the query builder until you manually reset them. So, if you want to clear the `where` condition of the previous query in the next query, you have the following options: […]

Laravel video is uploaded to OSS and transcoded using MPS

1. Create OSS storage space 2. Create media processing MPS 3. Install Alibaba Cloud oss SDK and MPS SDK composer require aliyuncs/oss-sdk-php composer require obacm/aliyun-openapi-mts 4. Use OSS upload + transcoding function //OSS upload public function OssUploadFile(Request $request) {<!– –> $accessKeyId = ”; $accessKeySecret = ”; // Endpoint takes Shenzhen as an example. Please fill […]

Laravel9 uses Mqtt

1. Create a custom command controller php artisan make:command MqttSubscribe This command will generate a MqttSubscribe.php class under app/Console/Commands 2. Modify MqttSubscribe.php <?php namespace App\Console\Commands; use App\extend\mqtt\MqttServer; use Illuminate\Console\Command; use Illuminate\Support\Facades\Cache; //php artisan make:command MqttSubscribe /** * Subscribe to MQTT messages * Class MqttSubscribe * @package App\Console\Commands */ class MqttSubscribe extends Command { /** * […]