mkdir rover cd rover git init
composer.json
: { "name": "mars-rover/mars-rover", "license": "MIT", "type": "project", "description": "Mars Rover", "require": { "php": "^7.0" } }
.gitignore
to ignore third-party library files in the repository: # Third Party libraries /vendor/
composer
: composer install --optimize-autoloader
git add composer.json .gitignore git commit -m '0: Created project'
navigation
packagewrite-only
and read-only
:write-only
write-only
read-only
write-only
logic separately from read-only
. Landing and driving are all about navigation, so let's start with it: git checkout -b 1-navigation mkdir -p packages/navigation cd packages/navigation
composer.json
for the new package: { "name": "mars-rover/navigation", "license": "MIT", "type": "library", "description": "Mars Rover - Navigation", "autoload": { "psr-4": { "MarsRover\\Navigation\\": "src/MarsRover/Navigation" } }, "require": { "php": "^7.0" }, "require-dev": { "memio/spec-gen": "^0.6" } }
phpspec.yml.dist
: extensions: Memio\SpecGen\MemioSpecGenExtension: ~
git
for this package by creating a .gitignore
file: # Configuration /phpspec.yml # Third Party libraries /vendor/ /composer.lock
Composer
: composer install --optimize-autoloader
git add -A git commit -m '1: Created Navigation package'
navigation
package to a project cd ../../
navigation
in the composer.json
file of our main project: { "name": "mars-rover/mars-rover", "license": "MIT", "type": "project", "description": "Mars Rover", "repositories": [ { "type": "path", "url": "./packages/*" } ], "require": { "mars-rover/navigation": "*@dev", "php": "^7.0" } }
Composer
only searches for Packagist packages . Having added a new section repositories
we tell it to check the availability of packages also locally in ./packages
, which allows us to use the found packages in the require
section.*
(any). But in order to be able to use the latest changes, not only with version tags, we need to specify the preferred stability ( @dev
).phpspec
for our tests, we put the dependency in the main project and on it: composer require --dev phpspec/phpspec:^3.0
phpspec
will look for tests at the root of the project. We need to create phpspec.yml.dist
to report the presence of a navigation
package: suites: navigation: namespace: 'MarsRover\Navigation' src_path: packages/navigation/src spec_path: packages/navigation
.gitignore
: # Configuration /phpspec.yml # Third Party libraries /vendor/
Composer
and then phpspec
: composer update --optimize-autoloader ./vendor/bin/phpspec run
git add -A git commit -m '1: Added navigation package to main project'
git checkout master git merge --no-ff 1-navigation
Composer
we can create many layouts within one repository, and using the MonoRepo
approach, we can run all tests with one command.Source: https://habr.com/ru/post/314544/
All Articles