Download the PHP package dersonsena/yii2-skeleton without Composer
On this page you can find all versions of the php package dersonsena/yii2-skeleton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dersonsena/yii2-skeleton
More information about dersonsena/yii2-skeleton
Files in dersonsena/yii2-skeleton
Package yii2-skeleton
Short Description A new approach for yii2 basic template
License BSD-3-Clause
Homepage http://www.yiiacademy.com.br
Informations about the package yii2-skeleton
Yii 2 Skeleton
Yii 2 Skeleton is a new approach to a design skeleton using Yii 2 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
The minimum requirement by this project template that your Web server supports PHP 8+.
RESOURCES
- Nginx + PHP 8.1 with Docker using Webdevops Images
- PHP Unit 9.5
- Yii2 Bootstrap 5 Extension
- PHP Codesniffer 3.5
- PHP Codesniffer Fixer 3
INSTALLATION
Install via Composer
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
You can then install this project template using the following command:
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):
NOTE: the commented environment variables are optional and your values set here is its default value.
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:
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:
COHESIVE CONTROLLER
Trying to follow the best programming practices, this boilerplate has a controller type called CohesiveController 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 and add your route such as:
The next step is create your CohesiveXptoRoutineController
class extending from App\Core\Controller\CohesiveController
and implement the handle()
method, as below:
Finally, access your Cohesive action: http://localhost:8080/specific/route/to/cohesive/a/controller
THE USEFUL MAKEFILE
The makefile file has several commands to help with day-to-day work. In it you can execute commands inside the container by typing a few letters in your terminal.
If you wanted to install or update the dependencies of your application, you should do something like:
For you not to have to write all this, use make
:
Thanks @wilcorrea for showing me this simple yet useful approach.
The makefile of skeleton comes with the following commands:
-
install
Perform composer install with optimize autoloaders parameter
ex.:make install
-
require
Perform composer require with the PACKAGE parameter
ex.:make PACKAGE="vendor/package" require
-
dump
Run composer command
dump-autoload
ex.:make dump
-
migrate
Alias to execute
yii migrate
in app container and run all migrations that are not applied
ex.:make migrate
-
migrate-create
Create a new migration in the project
ex.:make NAME="my-cute-migration" migrate-create
-
migrate-down
Rollback the last migration
ex.:make migrate-down
-
cache-clear
Just run the
yii cache/flush-all
into app container
ex.:make cache-clear
-
db-backup
Generate a
backup.sql
in the project root dir with a hot backup
e.:make db-backup
-
db-restore
Import a
backup.sql
that are in the project root dir to database container
e.:make db-restore
All versions of yii2-skeleton with dependencies
ext-intl Version *
ext-json Version *
yiisoft/yii2 Version ~2.0.45
yiisoft/yii2-bootstrap5 Version ~2.0.2
yiisoft/yii2-swiftmailer Version ~2.1.3
vlucas/phpdotenv Version ^5.3