nemo64 / environment
Base php environment
Installs: 9
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:composer-plugin
Requires
- php: 7.1.* || 7.2.*
- composer-plugin-api: ^1.1
- symfony/options-resolver: >= 2.6, < 5.0
- symfony/yaml: >= 2.8, < 5.0
- webmozart/path-util: ^2.3
Requires (Dev)
- composer/composer: ^1.3
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^7.0
This package is not auto-updated.
Last update: 2022-02-01 13:12:48 UTC
README
a basic php development environment
This composer plugin aims to be an assist in building your base environment in potentially multiple projects.
It does that by providing apis to define common config files. It is also highly extendable so you can add your own configurations for what your needs are.
start a new project
mkdir your_project_folder && cd your_project_folder
composer init -n
composer require --dev nemo64/environment
Now control your environment using make
. To see what you can do run make help
.
Basically you want to run make start
to start your local server and make stop
to stop it.
Your webserver is by default available under localhost:80
.
what files are created and by what
docker-compose.yml
andDockerfile-*
s will be generated byDockerConfigurator
. Those files will written using theChecksumArea
strategy. You may edit/add/remove lines as you please but try to avoid it since those lines will not be changed afterwards.PhpConfigurator
will add the chialab/php (apache) image based on the version defined by composersplatform.php
.
.gitignore
is created by theGitignoreConfigurator
. To modify the gitignore just write into it. The generator will see your rules and merge them with the rules it is supposed to add. If you want to remove a rule, put#
in front of it and it the rule won't be added again.ComposerConfigurator
will add thevendor
folder.DockerConfigurator
will add adocker-compose.log
file.
Makefile
will be generated byMakefileConfigurator
.ComposerConfigurator
will add avendor
target depending oncomposer.*
files to automatically runcomposer install
when needed.DockerConfigurator
will add the phony targetsstart
,stop
andclean
. Also adocker-compose.log
target will be added which runs the build process when a dockerfile changes.
how it works
Other than most scaffold projects, this is a composer plugin and aims to not only create your base files but also to update them.
This plugin will run on every composer install
and composer update
, checks if some conditions have changed and potentially updates some files.
For example:
- you get a basic docker php environment that is keeped up to date with your composer configured
platform.php
version. - you get a
makefile
to easily start/stop and install your project (just runmake serve
) to install and start everything. Depending on your configuration you can also add other dependency management commands to the install command. - your .gitignore file will always contain all installed libraries even if they are installed outside the vendor dir which is common for older projects like typo3.
These is just the basic functionality. You can implement your own rules by creating a class extending the ConfiguratorInterface
. In this class you'll be able to either create your own files or configure the already existing Configurators eg. to add more gitignore rules.
extend functionality
Configurators aren't limited to other composer-plugins. You can add them to your root project or even other libraries if they need to add something to a project outside their folder. If you need to add a file to the projects .gitignore
file, you can simply add your own Configurator like this:
<?php class MyConfigurator implements \Nemo64\Environment\Configurator\ConfiguratorInterface { public function getInfluences(): array { return [ \Nemo64\Environment\Configurator\GitignoreConfigurator::class, ]; } public function configure(\Nemo64\Environment\ExecutionContext $context): void { $context->get(\Nemo64\Environment\Configurator\GitignoreConfigurator::class)->add('/tmpdir'); } }
And hint to the file in your composer.json
:
{ "extra": { "nemo64/environment": { "classes": ["Namespace\\MyConfigurator"] } } }
Done. Your configure
method will be called every time you use composer. You can check if other extensions get installed, read config files. Even ask the user questions using io (but be sure those are only asked once).
Guideline
If you want your configurator to be useful, make sure it is highly adaptive. The GitignoreConfigurator
won't remove rules you have made and even preserves comments. Therefor an outside user does not have to learn a new way of configuring a file that is right there. He just adds a rule and it works as expected.