承接 vtardia/simphle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vtardia/simphle

最新稳定版本:1.0.3

Composer 安装命令:

composer require vtardia/simphle

包简介

A quick and simple PHP server for development

关键字:

README 文档

README

Simphle is a friendly wrapper for PHP built-in web server, with some handy features for an easy developement.

Requirements

Installation

  1. Composer
$ composer [global] require vtardia/simphle

Use the global option to install it globally on your system

  1. Custom

Clone this repository to a shared directory, for example /usr/local/php/simphle or /Users/Shared/php/Simphle on a Mac, then run composer install.

Add the bin directory to your local path or create a link to the bin/simphle executable:

   $ ln -s /usr/local/php/simphle/bin/simphle ~/bin/simphle

Usage

Basic

Start a server with default settings in the current directory:

$ cd /path/to/myapp/docroot
$ simphle

Intermediate

Start a server with custom settings from the command line:

$ cd /path/to/myapp
$ simphle [-H host] [-p port] [-c path/to/php.ini] [-r path/to/router.php] [path/to/docroot]

Advanced

Create a server.json file in your project's directory with your custom settings and then launch simphle from inside that path.

{
    "host":"0.0.0.0",
    "port":5000,
    "docroot":"public",
    "router":"myrouter.php|default",
    "ini":"mysettings.ini|default",
    "controller": "mycontroller.php",
    "env": {
        "myvar": "somevalue",
        "anothervar": {
            "one": "foo",
            "two": "bar"
        }
    }
}

The router and ini file paths are relative to the current working directory. The main Simphle script searches for these files in the current working directory first, then in Simphle's share directory. The .php and .ini extensions are not required for preset router and INI files.

The controller file path is relative to the document root directory.

Launch it with Composer

Create a scripts section in you composer.json:

"scripts": {
    "server": "simphle [options]"
}

Then launch it using

$ composer server

The default router

Simphle's default router tries to simulate a typical Apache .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

If the requested URI exists tries to fetch it, if not it searches for an index.php, finally falls back to a "404 not found" error.

Using a front controller

By specifying a controller settings Simphle uses this file as rewrite target instead of index.php, so you can use for example app.php.

Customizing the environment

The env section defines environment variables that are passed to the PHP files through the $_ENV superglobal. JSON objects are converted to associative arrays.

Sometimes the $_ENV superglobal is not populated. It depends on the variables_order settings in php.ini:

; This directive determines which super global arrays are registered when PHP
; starts up. If the register_globals directive is enabled, it also determines
; what order variables are populated into the global space. G,P,C,E & S are
; abbreviations for the following respective super globals: GET, POST, COOKIE,
; ENV and SERVER. There is a performance penalty paid for the registration of
; these arrays and because ENV is not as commonly used as the others, ENV is
; is not recommended on productions servers. You can still get access to
; the environment variables through getenv() should you need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order
variables_order = "GPCS"

This setting can be overridden by local htaccess or php.ini files.

License

Simphle is licensed under the MIT License - see the LICENSE file for details

统计信息

  • 总下载量: 53
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-27