PHP Framework
Laravel
Detailed explanation of laravel one-click installation package installation and HTTP basic routingDetailed explanation of laravel one-click installation package installation and HTTP basic routing
The following are the notes I compiled while watching videos on the php Chinese website for your reference. The following are some basic knowledge. If you are not familiar with the basic knowledge, you can take a look. The last article I shared was about composer installing laravel. If you want to see more articles, follow me. I hope I can help you.
Several ways to download and install Laravel
One-click installation package download:
http://www.golaravel.com/download/
github download
https://github.com/laravel/laravel
Download zip directly Package
SourceTree clone download
1. Laravel initialization configuration
1. Check the corresponding version requirements of laravel
2. Enable httpd in apache. For the rewrite and vhost of the conf file, change none of the httpd.conf file to all
3. Configure the httpd-vhosts.conf file
DocumentRoot "c:/code/blog/" ServerName blog.hd
4. Configure the hosts file:
127.0.0.1 blog.hd
5. Open the PHP extension php.ini
extension=php_openssl.dll extension=php_mbstring.dll extension=php_pdo_mysql.dll
2. Run Laravel to start the welcome page
1. Use the download and installation method to install laravel. You need to regenerate the key and switch to Execute
php artisan key:generate
2 in the project directory. Modify the default home page and pseudo-static configuration file (.htaccess)
Entry file:
public下index.php
or server.php## in the root directory
#Access URL:hd.cn/public/index.phpor hd.cn/server.phpOptimize access, change to use hd.cn to access (1) Change server.php to index.php and you can access hd.cn(2) Copy the pseudo-static configuration file .htaccess to the root directory and the same level as index.php. Another methodWhen configuring the httpd-vhosts.conf file
DocumentRoot "c:/code/blog/" ServerName blog.hdis modified to:
DocumentRoot "c:/code/blog/public/" ServerName blog.hdThis method is:Configuring the entry directoryvhost file modification apache\conf\extra\httpd-vhosts.conf
Note: Independent server, with permission to modify the entry file directory or subdirectory binding domain name Use this method in this case3. Detailed explanation of laravel HTTP basic routing1. Laravel has the following routesServerAdmin webmaster@dummy-host2.example.com DocumentRoot "c:/code/blog/public/" ServerName blog.hd Errortog "loqs/dummy-host2.example.com-error.log" Customlog "logs/dummy-host2.example.com-access.log" common
Route:: get('/hd', function () {
echo "get";
});
Route:: post('/hd', function () {
echo "post";
});
Route::put('/hd', function () {
echo "put";
});
Route::delete('/hd', function () {
echo "delete";
});
Route::patch('/hd', function() {
echo "patch":
});
Route::options ('/hd', function () {
echo "options"!
});match refers to matching the following routeRoute::match (['get','post','patch'], '/test', function () {
echo "match"!
}); any matches any routeRoute::any ('/hd', function () {
echo "any"!
});2. Route access controllerRount::get('/test','IndexController@index')Controller creation method:Create a controller named IndexController.php# under the controller package
## (1), manual creation
<?php
namespace App\Http\Controllers;
class IndexController extends Controller{
public function index(){
echo 12121212;
}
}(2), Artisan method creation
php artisan make:controller HomeController
3, controller is divided into folders
because the controller is divided into front desk Controller and background controller, so we divide the folder into folders and move the IndexController.php controller from the Controller root directory to the Admin folder under the Controller
(1), modify the routing
Rount::get('/test','IndexController@index')
Change to
Rount::get('/test','Admin\IndexController@index')
(2), modify the namespace
namespace App\Http\Controllers;
to
namespace App\Http\Controllers\Admin;
(3), because the inherited Controller cannot be found, so add the following reference,
use App\Http\Controllers\Controller; //就是上级目录Controllers然后找到Controller文件
The above steps are my study notes. I wrote down the steps or key points to be operated. If you don’t understand anything, you can leave a message. Thank you for your support. I hope it can help Xiaobai. If you want to see more information, follow me and continue to share in the next article.
The above is the detailed content of Detailed explanation of laravel one-click installation package installation and HTTP basic routing. For more information, please follow other related articles on the PHP Chinese website!
Using Laravel: Streamlining Web Development with PHPApr 19, 2025 am 12:18 AMLaravel optimizes the web development process including: 1. Use the routing system to manage the URL structure; 2. Use the Blade template engine to simplify view development; 3. Handle time-consuming tasks through queues; 4. Use EloquentORM to simplify database operations; 5. Follow best practices to improve code quality and maintainability.
Laravel: An Introduction to the PHP Web FrameworkApr 19, 2025 am 12:15 AMLaravel is a modern PHP framework that provides a powerful tool set, simplifies development processes and improves maintainability and scalability of code. 1) EloquentORM simplifies database operations; 2) Blade template engine makes front-end development intuitive; 3) Artisan command line tools improve development efficiency; 4) Performance optimization includes using EagerLoading, caching mechanism, following MVC architecture, queue processing and writing test cases.
Laravel: MVC Architecture and Best PracticesApr 19, 2025 am 12:13 AMLaravel's MVC architecture improves the structure and maintainability of the code through models, views, and controllers for separation of data logic, presentation and business processing. 1) The model processes data, 2) The view is responsible for display, 3) The controller processes user input and business logic. This architecture allows developers to focus on business logic and avoid falling into the quagmire of code.
Laravel: Key Features and Advantages ExplainedApr 19, 2025 am 12:12 AMLaravel is a PHP framework based on MVC architecture, with concise syntax, powerful command line tools, convenient data operation and flexible template engine. 1. Elegant syntax and easy-to-use API make development quick and easy to use. 2. Artisan command line tool simplifies code generation and database management. 3.EloquentORM makes data operation intuitive and simple. 4. The Blade template engine supports advanced view logic.
Building Backend with Laravel: A GuideApr 19, 2025 am 12:02 AMLaravel is suitable for building backend services because it provides elegant syntax, rich functionality and strong community support. 1) Laravel is based on the MVC architecture, simplifying the development process. 2) It contains EloquentORM, optimizes database operations. 3) Laravel's ecosystem provides tools such as Artisan, Blade and routing systems to improve development efficiency.
Laravel framework skills sharingApr 18, 2025 pm 01:12 PMIn this era of continuous technological advancement, mastering advanced frameworks is crucial for modern programmers. This article will help you improve your development skills by sharing little-known techniques in the Laravel framework. Known for its elegant syntax and a wide range of features, this article will dig into its powerful features and provide practical tips and tricks to help you create efficient and maintainable web applications.
The difference between laravel and thinkphpApr 18, 2025 pm 01:09 PMLaravel and ThinkPHP are both popular PHP frameworks and have their own advantages and disadvantages in development. This article will compare the two in depth, highlighting their architecture, features, and performance differences to help developers make informed choices based on their specific project needs.
Laravel user login function listApr 18, 2025 pm 01:06 PMBuilding user login capabilities in Laravel is a crucial task and this article will provide a comprehensive overview covering every critical step from user registration to login verification. We will dive into the power of Laravel’s built-in verification capabilities and guide you through customizing and extending the login process to suit specific needs. By following these step-by-step instructions, you can create a secure and reliable login system that provides a seamless access experience for users of your Laravel application.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.





