I always want to do a small project by myself, but I don’t know how to start. I always do a certain part of the project when I go to work, and I don’t do a project as a whole. The following is a summary of the videos I watched on the PHP Chinese website. Notes for your reference. This is a practical blog project done in a Windows environment.
1. Create the project
1) Switch to the project directory (I put all the projects in the code folder)
cd code
2) Create Project (the project name is blog)
composer create-project laravel/laravel blog --prefer-dist 指优先安装压缩版
2. Distribute routing and verification code references
1) First assign a route (each reference address must be assigned Routing)
After the creation is successful, check whether it can be successfully accessed
2) Reference the third-party library (under the resource folder, represented by org)
3) In the controller Load class require_once '../resources/org/code/Code.class.php';
session_start();
The laravel framework itself encapsulates the session. It is possible to use the native session when referencing the extension class. The entry file index.php enables the call of the
require_once '../resources/org/code/Code.class.php'; //先把类包含进来,实际路径根据实际情况进行修改。 $code = new Code(); //实例化一个对象 $code->doimg(); $_SESSION['code'] = $code->getCode();//验证码保存到SESSION中
image: use the routing access method
{{url('') }}
It is possible that the verification code is not clear:
This is when we add a click event to create a new verification code every time we clickalt="' onclick=" this.src='{{'home/code'}}'"
Some browsers will think that the address has not changed, so the verification code remains unchanged
alt="' onclick="this.src='{{'home/code'}}?'-Math.random()"
3. Login form submission CRFS authentication and verification code judgment
1) Note that when submitting the form, the submit button must be in