Home > PHP Framework > ThinkPHP > How to install thinkphp

How to install thinkphp

下次还敢
Release: 2024-04-09 17:42:23
Original
1167 people have browsed it

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

How to install thinkphp

How to install ThinkPHP

Step one: Environment preparation

Before installing ThinkPHP, you need to meet the following environment requirements:

  • PHP >= 7.2
  • Composer >= 2.0
  • MySQL database

Step 2: Create the project

Use Composer to create a new ThinkPHP project:

<code class="bash">composer create-project topthink/thinkp project-name</code>
Copy after login

Step 3: Install dependencies

Enter the project directory and install the ThinkPHP framework and dependencies:

<code class="bash">cd project-name
composer install</code>
Copy after login

Step 4: Configure the database

In config/database.php Configure the database connection in the file:

<code class="php">return [
    // 数据库类型
    'type'        => 'mysql',
    // 数据库主机名
    'hostname'    => 'localhost',
    // 数据库用户名
    'username'    => 'root',
    // 数据库密码
    'password'    => 'password',
    // 数据库名
    'database'    => 'project-name',
    // 数据库端口
    'port'        => 3306,
];</code>
Copy after login

Step 5: Generate the application

Run the generator command to generate the basic application code:

<code class="bash">php think app:generate</code>
Copy after login

Step 6: Start the application

In the development environment, use the built-in WEB server to start the application:

<code class="bash">php think run</code>
Copy after login

Visithttp://localhost:8000 , you can see the default interface of ThinkPHP application.

The above is the detailed content of How to install thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template