[php]Built-in HTTP server

PHP: Hypertext Preprocessor
回复
头像
vicyang
版主
版主
帖子: 56
注册时间: 2016年07月21日 20:35
联系:

[php]Built-in HTTP server

帖子 vicyang »

浅尝 PHP,循着两篇环境搭建的文章探索了良久(惭愧地说,花了1个钟吧)。

这两篇文章分别是
how-to-install-php-on-windows
how-to-install-apache-on-windows

虽然里面有说 XAMPP 是比较省心的方案,但作为不折腾会死党,还是想手动配置一次,折腾完以后翻开 Modern PHP (PDF) 一看:

Built-in HTTP server
Did you know that PHP has a built-in web server as of PHP 5.4.0? This is another
hidden gem unknown to PHP developers who assume they need Apache or nginx to
preview PHP applications. You shouldn't use it for production, but PHP’s built-in web
server is a perfect tool for local development.

I use PHP's built-in web server every day, whether I'm writing PHP or not. I use it to
preview Laravel and Slim Framework applications. I use it while building websites
with the Drupal content-management framework. I also use it to preview static
HTML and CSS if I'm just building out markup.

Start the Server
It's easy to start the PHP web server. Open your terminal application, navigate to your
project's document root directory, and execute this command:
  • php -S localhost:4000
This command starts a new PHP web server accessible at localhost. It listens on port
4000. Your current working directory is the web server's document root.

:coverface1

--
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客