This repo contains tools to set up a development environment for Yii 3 packages. It allows to work on separate packages and test the result in other packages at the same time.
If you prefer manual install, you need:
- GNU/Linux or Windows with bash
- PHP 7.4 or higher
- Composer installed and
available as
composer
on the command line
If you prefer Vagrant, you only need to install Vagrant and VirtualBox, because our Vagrant environment already contains Ubuntu, PHP and Composer. See our Vagrant documentation for details.
If you prefer Docker, you only need to install Docker.
git clone https://github.com/yiisoft/yii-dev-tool
cd yii-dev-tool
composer install
./yii-dev install
The above command will clone all Yii 3 packages and run composer install
in them.
You may select packages by providing a second argument:
./yii-dev install di,rbac,yii-cycle,view
Tip: You can speed up Composer significantly by installing prestissimo plugin globally.
Note: In case you are using PhpStorm you have to add
yiisoft
exclusion pattern in "Settings → Directories → Exclude Files". Else it would go into infinite indexing cycle.
To upgrade yii-dev-tool to the latest version, run the following commands:
cd yii-dev-tool
git pull
composer update
To customize the configuration of yii-dev-tool, create your local configuration packages.local.php
using file packages.local.php.example
as example. In this file you will find examples of all available
configuration options.
If you want to run yii-dev-tool in a Docker container, run the following command:
docker-compose run --rm php bash
Add SSH keys or configure to use HTTPS.
Afterwards you can run the above commands like ./yii-dev install
.
Suppose we want to work on three interdependent packages:
- yiisoft/yii-demo
- yiisoft/view
- yiisoft/i18n
Package yii-demo depends on package view, and package view depends on package i18n.
Suppose we want to add new features to package i18n, and then use them in package view. After that, we will need to run the tests in package yii-demo and make sure that everything works correctly.
Go to the page of each repository and click the "Fork" button:
Suppose my nickname on Github is "samdark". Then I will get three forks:
- samdark/yii-demo
- samdark/view
- samdark/i18n
For your nickname you will get other fork names.
Now install yii-dev-tool:
git clone https://github.com/yiisoft/yii-dev-tool
cd yii-dev-tool
composer install
In order for yii-dev-tool to use our forks, they must be configured. Create your configuration:
cd yii-dev-tool
cp packages.local.php.example packages.local.php
Specify the forks in config packages.local.php
:
$packages = [
'yii-demo' => 'samdark/yii-demo',
'view' => 'samdark/view',
'i18n' => 'samdark/i18n',
];
See example.
Now install the packages:
cd yii-dev-tool
./yii-dev install yii-demo,view,i18n
This command clones the fork repositories from GitHub to the local directory yii-dev-tool/dev/
,
sets upstream
for them and executes composer install
in each package. Then symlinks will be created:
- yii-dev-tool/dev/yii-demo/vendor/yiisoft/view -> yii-dev-tool/dev/view
- yii-dev-tool/dev/view/vendor/yiisoft/i18n -> yii-dev-tool/dev/i18n
Due to these symlinks, changes in packages will immediately affect the operation of packages that depend on them. It is very convenient for development.
Create a new feature-x branch in the repositories:
cd yii-dev-tool
./yii-dev git/checkout-branch feature-x yii-demo,view,i18n
Now make the necessary changes to the code of package i18n in folder yii-dev-tool/dev/i18n
.
Next, make changes to the code of package view in folder yii-dev-tool/dev/view
.
And, finally, change package yii-demo in folder yii-dev-tool/dev/yii-demo
.
Make sure the tests pass. For instance, package yii-demo tests can be run with the following command:
cd yii-dev-tool/dev/yii-demo
./vendor/bin/phpunit
Commit the changes:
cd yii-dev-tool
./yii-dev git/commit "Add feature X" yii-demo,view,i18n
Push the new code to remote repositories:
cd yii-dev-tool
./yii-dev git/push yii-demo,view,i18n
Go to the pages of the original repositories and create a PR in each:
That's all. We developed new functionality and submitted it for review 🙂 Of course, the steps will be slightly different for different tasks and configurations.
Remember that yii-dev-tool contains many other commands for working with repositories:
./yii-dev exec
– executes the specified console command in each package./yii-dev git/checkout-branch
– creates, if not exists, and checkout a git branch./yii-dev git/commit
– add and commit changes into each package repository./yii-dev git/pull
– pull changes from package repositories./yii-dev git/push
– push changes into package repositories./yii-dev git/status
– show git status of packages./yii-dev install
– install packages./yii-dev lint
– check packages according to PSR12 standard./yii-dev replicate/files
– copy files specified inconfig/replicate/files.php
into each package./yii-dev replicate/composer-config
– mergeconfig/replicate/composer.json
intocomposer.json
of each package./yii-dev update
– update packages
If you encounter any problems, create an issue – and we'll try to help you.