PHPackages                             lyw0301/yaf-starter-kit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. lyw0301/yaf-starter-kit

ActiveLibrary[Framework](/categories/framework)

lyw0301/yaf-starter-kit
=======================

Yaf 快速开发工具包，项目模板.

10PHP

Since Apr 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/lyw0301/yaf-starter-kit)[ Packagist](https://packagist.org/packages/lyw0301/yaf-starter-kit)[ RSS](/packages/lyw0301-yaf-starter-kit/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Yaf starter kit
===============

[](#yaf-starter-kit)

The Yaf testable starter kit and composer supported.

集成 illuminate/database, 极大的方便在 Yaf 中进行数据库操作。

Requirement
===========

[](#requirement)

- PHP &gt;= 7.0
- Yaf &gt;= 3.0

Installation
============

[](#installation)

1. Update `yaf.ini`:

```
[yaf]
yaf.use_namespace=1
yaf.use_spl_autoload=1
...

```

2. Create project.

```
$ composer create-project lyw0301/yaf-starter myapp -vvv
```

3. Web server rewrite rules:

    #### Apache

    [](#apache)

    ```
    #.htaccess
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* index.php

    ```

    #### Nginx

    [](#nginx)

    ```
    server {
      listen 80;
      server_name  mongochina.com;
      root   /path/to/mongochina;
      index  index.php index.html index.htm;

      if (!-e $request_filename) {
        rewrite ^/(.*)  /index.php/$1 last;
      }
    }

    ```

    #### Lighttpd

    [](#lighttpd)

    ```
    $HTTP["host"] =~ "(www.)?mongochina.com$" {
      url.rewrite = (
         "^/(.+)/?$"  => "/index.php/$1",
      )
    }

    ```

Application structor
====================

[](#application-structor)

```
├── .scripts
│   ├── .gitkeep
│   ├── common.sh
│   ├── job_phpcs.sh
│   ├── job_phpmd.sh
│   ├── job_phpunit.sh
│   ├── sami.phar
│   └── sami.php
├── app
│   ├── commands                # yaf commands (namespace：\App\Commands)
│   ├── controllers             # Yaf Controllers (namespace：\)
│   ├── models                  # Yaf Models (namespace：\)
│   ├── exceptions              # Exceptions (namespace：\App\Exceptions)
│   ├── facades                 # Service Facades (namespace：\)
│   ├── plugins                 # Yaf plugins (namespace：\)
│   ├── presenters              # Object presenters (namespace：\App\Presenters)
│   ├── services                # Services, the 3rd service bridges (namespace：\App\Services)
│   ├── traits                  # Traits (namespace：\App\Traits)
│   ├── views                   # Template files
│   ├── helpers.php             # Herlpers
│   ├── Bootstrap.php           # Yaf Bootstrap file
├── config
│   ├── application.ini     # Yaf config file
├── public                  # web extrence
│   └── index.php
├── yaf                     # The command line tool
├── tests                   # Unit tests
└── vendor                  #
├── phpunit.xml.dist        # PHPUnit config file
├── .gitignore
├── .php_cs                 # PHP-CS-Fixer config file
├── composer.json
├── composer.lock
├── README.md

```

Controllers
===========

[](#controllers)

```
$ ./yaf make:controller Foo_Bar # or：foo_bar/FooBar/FooBarController
#
# /www/mongochina.com/app/controllers/Foo/Bar.php Created!
# /www/mongochina.com/tests/controllers/Foo/BarTest.php Created!
```

All controllers are created in the `app/controllers` directory，and test files are also created in the `tests/controllers` directorty.

Of course, you can also create tests independently：

```
$ ./yaf make:test Foo_Bar # Also supports multiple type controller names
# /www/mongochina.com/tests/controllers/Foo/BarTest.php Created!
```

### The handle() method

[](#the-handle-method)

The controller entry method `handle()`:

```
