Skip to content

Added an initial documentation for Symfony Flex recipes #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

javiereguiluz
Copy link
Member

It's based on your blog posts and the source code of Flex.

@fabpot
Copy link
Member

fabpot commented Apr 6, 2017

I've just added one more option: version_aliases. Right now, there is only one recipe using it, phpunit. Basically, it lists all additional versions that work with the recipe.

For Symfony, instead of duplicating all recipes when 3.4 is out, we can just add it to version_aliases for each 3.3 recipe. If one recipe should be different, then we need to duplicate the recipe (we might want to use symlinks to avoid too many duplications though).

README.rst Outdated
.. code-block:: json

{
"version_aliases": ["3.3", "3.4", "4.0-dev"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "4.0".

README.rst Outdated
``aliases`` option
~~~~~~~~~~~~~~~~~~

The main configuration option is called ``aliases`` and its value is an array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that this is the main configuration option

README.rst Outdated

Developers can now install this dependency as ``composer require acme-log``. For
security reasons, and to improve Symfony's developer experience, a long list of
aliases are reserved by Symfony Flex (``orm``, ``mailer``, ``loger``, ``admin``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger?

README.rst Outdated
Developers can now install this dependency as ``composer require acme-log``. For
security reasons, and to improve Symfony's developer experience, a long list of
aliases are reserved by Symfony Flex (``orm``, ``mailer``, ``loger``, ``admin``,
etc.) If you use those aliases in your recipe, they will be ignored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need this paragraph as we will be accepting or rejecting recipes before they get merged, so that's just a matter of reviewing the aliases.

README.rst Outdated

This option lists all the additional versions of the dependency that work with
this very same recipe (versions can use any of the syntaxes supported by
Composer). This avoids duplicating recipes when a new version of the package is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Versions should only be like x.y.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also probably add a note about the fact that the main version used as a directory should be the oldest supported version.

README.rst Outdated
Enables one or more bundles in the Symfony application by appending them to the
``bundles.php`` file. Its value is an associative array with the bundle
namespace as the keys and the array of environments where it must be enabled as
the value. Use ``all`` to enable the bundle in any existing environment:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably list all possible values. We do accept any values, but I think we need to restrict to the "default" supported Symfony envs: dev, test, prod.

README.rst Outdated
The ``%BIN_DIR%`` string is a special value that it's turned into the absolute
path of the binaries directory of the Symfony application. These are the special
variables available: ``BIN_DIR``, ``CONF_DIR``, ``ETC_DIR``, ``SRC_DIR`` and
``WEB_DIR``. You can also access to any variable defined in the ``extra`` section
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add the % sign so that people can copy/paste them directly.

README.rst Outdated
"DB_HOST": "127.0.0.1",
"DB_NAME": "symfony",
"DB_USER": "root",
"DB_PASSWORD": ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can change the example as DB_ vars are now different.

README.rst Outdated
to execute them automatically when running ``composer install`` and ``composer update``.
The value is an associative array where the key is the script to execute (including
all its arguments and options) and the value is the type of script (``php-script``
for PHP scripts, ``script`` for Makefile tasks and ``symfony-cmd`` for Symfony
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script can really be any shell script, not just a make task.

README.rst Outdated
file and wrapped with section separators (``###> your-recipe-name-here ###``)
that must not be removed or modified.

``post-install-output`` configurator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use Configurator with a capital letter.

README.rst Outdated
~~~~~~~~~~~~~~~~~~~~~~~~~~

This option lists all the additional versions of the dependency that work with
this very same recipe (versions can use any of the syntaxes supported by
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sentence inside parenthesis is wrong

README.rst Outdated

Enables one or more bundles in the Symfony application by appending them to the
``bundles.php`` file. Its value is an associative array with the bundle
namespace as the keys and the array of environments where it must be enabled as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the bundle class name, not the bundle namespace

README.rst Outdated
The ``%BIN_DIR%`` string is a special value that it's turned into the absolute
path of the binaries directory of the Symfony application. These are the special
variables available: ``BIN_DIR``, ``CONF_DIR``, ``ETC_DIR``, ``SRC_DIR`` and
``WEB_DIR``. You can also access to any variable defined in the ``extra`` section
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should give access only to extras containing a scalar value (currently, we don't validate it in symfony/flex, but an array would give you a notice and Array when casting it)

README.rst Outdated
Symfony Flex turns that recipe into the following content appended to the ``.env``
and ``.env.dist`` files:

.. code-block:: ini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bash would be better than ini, as the syntax of the .env file is based on Bash (it is meant to allow using source .env too in case you use explicit exports)

README.rst Outdated
]
}

.. _`Symfony Flex`: https://github.com/fabpot/flex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it expected to stay there ? If we want to move it to the symfony org as soon as it is open-sourced, I suggest using directly the target URL to avoid forgetting to update it

README.rst Outdated
All the contents of the ``manifest.json`` file are optional and they are divided
into options and configurators.

.. TODO: explain that recipe contents must be versioned
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also explain the directory structure: vendor/package/version where version is the minimum version supported by the recipe

README.rst Outdated

This option defines one or more alternative names that can be used to install
the dependency. Its value is an array of strings. For example, if a dependency
is published as the ``acme-inc/acme-log-monolog-handler``, it can define one or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is published as the

README.rst Outdated
"aliases": ["acme-log", "acmelog"]
}

Developers can now install this dependency as ``composer require acme-log``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as acme-log" or "with composer require acme-log"

README.rst Outdated
.. note::

When using ``version_aliases``, the directory where the recipe is defined
must be the oldest supported version (``3.3`` in the previous example).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be 3.2 here as you don't need to duplicate the version from the directory name. That's only additional versions.

README.rst Outdated
Enables one or more bundles in the Symfony application by appending them to the
``bundles.php`` file. Its value is an associative array where the key is the
bundle class name and the value is an array of environments where it must be
enabled. The supported environtments are ``dev``, ``prod``, ``test`` and ``all``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

environments <- typo

README.rst Outdated
}
}

The previous recipe is transformed by Symfony Flex into the following PHP code::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a README, you need to be explicit about highlighting, so you cannot use ::, but .. code-block:: php instead.

README.rst Outdated
"MAILER_HOST": "localhost",
"MAILER_PORT": "25",
"MAILER_USER": "",
"MAILER_PASSWORD": ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the DB, we are now using MAILER_URL :)

@fabpot
Copy link
Member

fabpot commented Apr 13, 2017

Thank you @javiereguiluz.

@fabpot fabpot closed this in 80e1aec Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants