• Explain the dependency injection function of laravel framework in detail


    catalogue summary Real examples conclusion summary Whenever you request a dependency in a controller class, the service container is responsible for: 1. Automatically detect dependencies in constructors 2. If you need to build this dependency 3. Create objects through constructors to form dependencies Let’s take a very simple example. <?php namespace App\Http\Controllers; use App\User; use […]

  • How to use laravel to include your own help functions


    Many tutorials will say that you are in composer This requirement can be achieved by adding an automatically loaded file to JSON. But I don’t think it’s a good way when you’re in helpers When more functions are added to the PHP file, the readability will become very poor. Now I will introduce a way […]

  • Talking about using slack to notify exceptions in laravel


    catalogue summary Install the maknz/slack–laravel package to configure Adjust the report method of the appexceptionshandler class summary Usually, we can rely on user feedback and often check the program log to find problems in the program. But this is either unreliable or not timely, so let’s introduce a more effective method — using slack to […]

  • Explain the advantages of laravel service container


    catalogue summary Advantages of using service containers Example 1: sending mail Example 2: implement the singleton mode Example 3: travelers travel summary summary The laravel service container is like a highly automated factory. You can customize the model and use specific interfaces to manufacture the things you need. Because the service container is used, most […]

  • On the idea of creating laravel Middleware


    Laravel middleware provides a mechanism to interrupt the original program flow, process some events through the middleware, or extend some functions without modifying the logic code. For example, logging middleware can easily record request and response logs without changing logic code. So let’s simplify the software execution process. Now there is a core class kernel, […]

  • How to encrypt large files in laravel


    I have searched the software package or solution used to solve this problem, and encountered the stack overflow answer and the PHP solution, which is basically the PHP implementation of the solution described by stack overflow. I decided to create an extension package designed for laravel to provide simple file encryption / decryption using simple […]

  • Talking about a method of dividing laravel routing files


    At first, I thought of using the routing group method to receive files. This is how laravel splits routes at the routeserviceprovider. <?php namespace App\Providers; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider{ protected $namespace = ‘App\Http\Controllers’; public function boot(){ parent::boot(); } public function map(){ $this->mapApiRoutes(); $this->mapWebRoutes(); } protected function mapWebRoutes(){ Route::middleware(‘web’) ->namespace($this->namespace) […]

  • How to verify files in zip in laravel


    catalogue summary Libzip extension for PHP How to manipulate zip files Integrated into laravel program Best practices summary If we want users to upload zip files, we can use them in combination with rules and as follows: return [ ‘file’ => ‘required|file|mimes:zip|size:3072’ ]; But unlike images, text, or PDF files, zip is a compressed file […]

  • How to use laravel eloquent to develop infinite classification


    catalogue summary Database migration Eloquent model and correlation Routing and controller methods Views and recursive subviews summary We will create a mini project to show the classification of children’s stores, with a total of 5 levels, as follows: Database migration Simple data table structure: Schema::create(‘categories’, function (Blueprint $table) { $table->bigIncrements(‘id’); $table->string(‘name’); $table->unsignedBigInteger(‘category_id’)->nullable(); $table->foreign(‘category_id’)->references(‘id’)->on(‘categories’); $table->timestamps(); }); […]

  • Analyze the use skills of five laravel dusks


    catalogue 1. fill in hidden fields 2. simulate HTML geographic location 3. using XPath selectors 4. full page screenshot 5. access the browser error log 1. fill in hidden fields When testing some JS components (such as auto completion, date selector, etc.), you may need to write action simulation operations to interact with these components. […]

  • Explain the API interface of laravel


    It should be noted that API has its specific purpose. We should know what it does. What should be entered when accessing the API. What you should get after accessing the API. When we begin to design the API, we should pay attention to these 8 points. The follow-up development plan revolves around this. 1.restful […]

  • Implementation example of adding permissions with laravel and Vue


    catalogue 1、 Add (permission) node 1.1 introduction of Vue 1.2. Add templates (Vue, jQuery) 1.3. Add node controller logic 1.4. Define modifiers in the model 1.5. Effect: 1、 Add (permission) node 1.1 introduction of Vue usevueManage the interface and realize the addition functionWe put it in this directoryvue.js: 1.2. Add templates (Vue, jQuery) resources/admin/node/create.blade.php: <!–_ […]