DescriptionPerformance has always been a point of Laravel framework, so tuning the Laravel program is a must-learn skill.Next share some of the best practices for development, as well as tuning tips, and you are welcome to comment on other suggestions.Here is a simple list:
Configure Information cachingartisan config:cache
Route cacheartisan route:cache
Class-Map Loading optimizationsartisan optimize
Automatic load optimizationcomposer dumpautoload
Using Memcached to sto
For details about how multiple Laravel Redis processes fetch queues at the same time, laravelredis
Preface
Recently, I encountered a problem in my work. Will multiple process processing queues read Redis queues repeatedly? Does this result in repeated task execution? The following is a detailed description of the sample code.
Use the Supervisor to listen to Laravel queue tasks. The Supervisor configuration is as follows:
[program:laravel-worker]process_name=%(program_name)s_%(process_num)02dcomm
to trigger an event each time a new chat room message is received.
Note: You need to familiarize yourself with the Laravel event broadcast mechanism to better understand this tutorial.So, first we create this event:
PHP Artisan make:event chatmessagewasreceivedOpen this newly generated class (app/events/chatmessagewasreceived.php) and make sure it's implemented Shouldbroadcast, and then we'll broadcast it to a "chat-room.1" Public channel.
Then we
application, you can use the Artisan command Config:cache to cache all configuration files in a single file, which merges all the configuration options into a single file and can be quickly loaded by the framework.
Once the application is online, the PHP artisan Config:cache is run once, but it is not necessary to run the command frequently when developing locally, because the configuration values often n
laravel to create applications. The new PSR-4 automatic loading standard has been adopted in the 5.0 edition from beginning to end. The following are the main new features of version 5.0:
Directory structure
The App/models directory in previous versions was removed entirely. Now you can put the code directly in the app directory, and all the code in that directory will be organized into the app namespace by default. This namespace can be modified with the addition of the new
On another machine pull up the latest code, into the background of the Web site, found that the page blank, using PHP artisan cache:clear, PHP artisan clear-compiled and so on to clear the cache and compile the file or not, open the PHP error log to view, found error:
Fatal error:declaration of Illuminate\\auth\\sessionguard::basic () must compatible \\auth\\supportsbasicauth::basic () in/usr/share/nginx/h
This article introduces databasemigrations, one of the most powerful functions in the Laravel5 framework. This article describes in detail the steps and methods of database migration, which is very practical, if you have any need, refer. Database migrations is one of laravel's most powerful functions. Database migration can be understood as the version controller of the database.
The database/migrations directory contains two migration files, one for creating a user table and the other for rese
Laravel-based migrate tutorial, laravelmigrate
Preface
As we all know, the current development and testing are completed by collaboration among multiple teams. Everyone has a local environment. In the past, we generally manually add data, for example, you can use SQL statements in the database queryserver to insert data. If there is a small amount of data, it would be quite easy, but if the data is too large, it would be very painful, but it would be very easy in Laravel, you can use data migrat
following command to perform the database migration operation:php artisan migrateThe following results are obtained:If you run a command error, check the database connection settings. Now that the database migration is complete, you can open localhost/learnlaravel5/public/homeRegister and log in.6. Model ModelsNext we will touch the most powerful part of Laravel, eloquent ORM, and run the following command:php ar
excellent command-line tool called Artisan, which can be used to generate framework code and database schemas, artisan can handle everything from database schema migration to resource and configuration management.Conventions better than configurationOne of the interesting features of Laravel is that it prescribes some pretty serious restrictions on how to build a Web application. Surprisingly, these restri
quickstart --prefer-dist
Install the Quickstart project
Of course, you can also clone the GitHub repository to install it locally:
git clone https://github.com/laravel/quickstart-basic quickstartcd quickstartcomposer installphp artisan migrate
If you do not know how to build a local development environment, refer to Homestead and installation documentation.3. prepare the database 3.1 for database migration
First, let's use migration to define d
1. Introduction
Laravel contains a simple way to populate a database-using the Fill class and test data. All fill classes are located in the Database/seeds directory. The class name of the fill class is entirely customizable, but it is best to follow certain rules, such as readability, such as Usertableseeder, and so on. When Laravel is installed, a Databaseseeder class is provided by default. From this class, you can use the call method to run other fill classes, allowing you to control the fi
very famous Ang Sul to engage in the installation artifact: Https://github.com/overtrue/latest-laravel
3. Database Setup and Migration
Laravel 5 Change the location of the database configuration to ' learnlaravel5/.env ', open this file, edit the following four items and modify it to the correct information:
Db_host=localhostdb_database=laravel5db_username=rootdb_password=password
It is recommended to create a new database named Laravel5, which is recommended for direct operation with the roo
, feel free to enter your mailbox and password if you get the following picture:
Congratulations ~ Laravel 5 is successfully installed!
Do not want to configure the image of the students, you can use Laravel industry very famous anzheng Chao engaged in installation artifacts: https://github.com/overtrue/latest-laravel
3. database creation and migration
Laravel 5 changed the database configuration to 'learnlaravel5/. env'. open this file, edit the following four items, and modify them to the cor
familiarize yourself with all the configuration items.
Directory Permissions
After installing Laravel, you need to configure some directory read and write permissions: The storage and Bootstrap/cache directories should be writable, and if you use the Homestead virtual machine as the development environment, these permissions are already set.
Apply Key
The next thing to do is to set the applied key (App_key) to a random string, and if you install it through the Composer or Laravel installer,
classmate, you can use the Laravel world very famous Ang Sul to do installation artifact: Https://github.com/overtrue/latest-laravel
3. Database establishment and migration
Laravel 5 Changed the location of the database configuration to ' learnlaravel5/.env ', opened the file, edited the following four items, modified to the correct information:
Db_host=localhost
db_database=laravel5
db_username=root
Db_password=password
It is recommended to create a new database named Laravel
Tags: logs comm ati color address composer code data srcFirst, the Database migrationLaravel's Database migration provides a series of related operations on databases, tables, fields, and indexes. 1. Create a migrationUse the Artisan command php Artisan make:migration create_links_table This will generate a friendly link migration class named 2017_05_06_151645_create_links_table.php in the Database/migratio
multicolumn secondary indexes. At the end of the test, TOKUDB's insertion rate remained at 14,532 Inserts/second whereas InnoDB had dropped to 1,607 ins Erts/second. That's a difference of over 9x.Platform:centos 5.6; 2x Xeon L5520; 72GB RAM; LSI MegaRAID 9285; 2x 256GB Samsung 830 in RAID0highest COMPRESSIONCompression is an always-on feature of Tokudb. We tested InnoDB compression with the values of key_block_size (4k and 8k) and with compression d
Laravel5 asynchronous queue usage
Laravel5 provides a complete queue function, which can be used with simple configuration. Here we will briefly record the usage of asynchronous queues.Configuration
The definition of the queue is not described here. To use Asynchronous queues, there are two key points:
1. Place the storage queue 2. Services that execute tasks
Openconfig/queue.phpThis is Laravel5's queue configuration file. First, we can usedefaultThe parameter specifies the default queue driver.
Chao engaged in installation artifacts: https://github.com/overtrue/latest-laravel
3. database creation and migration
Laravel 5 changed the database configuration to 'learnlaravel5/. env'. Open this file, edit the following four items, and modify them to the correct information:
DB_HOST=localhostDB_DATABASE=laravel5DB_USERNAME=rootDB_PASSWORD=password
We recommend that you create a database named laravel5. For the convenience of learning, we recommend that you use the root account for direct op
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.