2017 © Pedro Peláez
 

composer-plugin environment

Base php environment

image

nemo64/environment

Base php environment

  • Thursday, May 17, 2018
  • by Nemo641
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version Total Downloads License, (*1)

a basic php development environment

This composer plugin aims to be an assist in building your base environment in potentially multiple projects., (*2)

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., (*3)

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., (*4)

what files are created and by what

  • docker-compose.yml and Dockerfile-*s will be generated by DockerConfigurator. Those files will written using the ChecksumArea 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 composers platform.php.
  • .gitignore is created by the GitignoreConfigurator. 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 the vendor folder.
    • DockerConfigurator will add a docker-compose.log file.
  • Makefile will be generated by MakefileConfigurator.
    • ComposerConfigurator will add a vendor target depending on composer.* files to automatically run composer install when needed.
    • DockerConfigurator will add the phony targets start, stop and clean. Also a docker-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., (*5)

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 run make 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., (*6)

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., (*7)

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:, (*8)

<?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:, (*9)

{
    "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)., (*10)

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., (*11)

The Versions

17/05 2018

dev-master

9999999-dev

Base php environment

  Sources   Download

MIT

The Requires

 

The Development Requires

11/05 2018

v2.0.0

2.0.0.0

Base php environment

  Sources   Download

MIT

The Requires

 

The Development Requires

06/05 2018

v1.0.1

1.0.1.0

Base php environment

  Sources   Download

MIT

The Requires

 

The Development Requires

06/05 2018

v1.0.0

1.0.0.0

Base php environment

  Sources   Download

MIT

The Requires

 

The Development Requires