PHPackages                             dersonsena/yii2-skeleton - 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. [Templating &amp; Views](/categories/templating)
4. /
5. dersonsena/yii2-skeleton

ActiveProject[Templating &amp; Views](/categories/templating)

dersonsena/yii2-skeleton
========================

A new approach for yii2 basic template

2.0(4y ago)938[1 PRs](https://github.com/dersonsena/yii2-skeleton/pulls)BSD-3-ClausePHP &gt;=8

Since Jun 26Compare

[ Source](https://github.com/dersonsena/yii2-skeleton)[ Packagist](https://packagist.org/packages/dersonsena/yii2-skeleton)[ Docs](http://www.yiiacademy.com.br)[ RSS](/packages/dersonsena-yii2-skeleton/feed)WikiDiscussions Synced 2d ago

READMEChangelog (3)Dependencies (13)Versions (5)Used By (0)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Yii 2 Skeleton
==============

[](#yii-2-skeleton)

Yii 2 Skeleton is a new approach to a design skeleton using [Yii 2](http://www.yiiframework.com/) as a basis.

The motivation to make this new template was to try to organize the packages inside a `src` directory, keeping all the class there, ie a place where the main application code will be.

REQUIREMENTS
------------

[](#requirements)

The minimum requirement by this project template that your Web server supports PHP 8+.

RESOURCES
---------

[](#resources)

- Nginx + PHP 8.1 with Docker using [Webdevops Images](https://github.com/webdevops/Dockerfile)
- PHP Unit 9.5
- Yii2 Bootstrap 5 Extension
- PHP Codesniffer 3.5
- PHP Codesniffer Fixer 3

INSTALLATION
------------

[](#installation)

### Install via Composer

[](#install-via-composer)

If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).

You can then install this project template using the following command:

```
php composer.phar create-project dersonsena/yii2-skeleton skeleton

```

### Your Enviroments Variables

[](#your-enviroments-variables)

Make a copy of the `.env.sample` file, you can use `cp .env.sample .env` in your terminal to do that.

You can place your environment settings in `.env` file, as below (note the sample file is ready to basic usage):

```
# ---------
# Docker
# ---------
PROJECT_NAME=yii2-skeleton
DOCKER_APP_PORT=8080
DOCKER_APP_SSL_PORT=443
DOCKER_MYSQL_PORT=3306
XDEBUG_REMOTE_PORT=9000

# ---------
# Application
# ---------
YII_ENV=dev
YII_DEBUG=true
REQUEST_COOKIE_VALIDATION_KEY=YOUR_VALIDATION_KEY
ADMIN_PASSWORD=
# APP_TIMEZONE=America/Sao_Paulo
# APP_LANGUAGE=pt_BR
APP_BASE_URL=http://localhost:8088

# ---------
# Database
# ---------
DB_HOST=your-db-host
DB_USERNAME=root
DB_PASSWORD=secret
DB_DATABASE=your-db-name
DB_DATABASE_TEST=your-test-db-name
DB_SCHEMA_CACHE_DURATION=60

# ---------
# Mailer
# ---------
SMTP_HOST=
SMTP_PORT=465
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_ENCRYPTION=ssl
```

**NOTE:** the commented environment variables are optional and your values set here is its default value.

### Run your Application

[](#run-your-application)

Before anything change `PROJECT_NAME` env variable to your project name/alias. This one it will be used to prefixed the application containers and other stuff.

To start your application and start up your containers just run the follow command:

```
make run

```

The command above will start 2 docker containers: `yii2-skeleton-app` (Nginx + PHP 8.1) and `yii2-skeleton-db` (MySQL)

If you have set a `DOCKER_APP_PORT` environment variable to `8000`, you will can then access the yout application through the following URL:

```
http://localhost:8000

```

COHESIVE CONTROLLER
-------------------

[](#cohesive-controller)

Trying to follow the best programming practices, this boilerplate has a controller type called [CohesiveController](src/Shared/Controller/CohesiveController.php) to help you a create a controller class with a single action (aka `handle()` method) and a single responsibility.

To create a cohesive controller got to [config/routes.php](./config/routes.php) and add your route such as:

```
