Download the PHP package faz-b/configuration-silex-provider without Composer

On this page you can find all versions of the php package faz-b/configuration-silex-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package configuration-silex-provider

Simple configuration for Silex App

Rapid routing, view and global parameters definition through a human readable structured config file.

Once you choose your preferred parsable data format, register the ConfigurationServiceProvider.

# src/app.php

# $configuration = json_decode(file_get_contents(__DIR__ . '/Site/Resource/config/config.json'), true);
$configuration = Yaml::parse(file_get_contents(__DIR__ . '/Site/Resources/config/config.yml'));
$app->register(new ConfigurationServiceProvider(), array('site.config' => $configuration));

The key

Allows to define your routes and view variables. The first key, under the key is your route name. All routes defined here are registered with the .

# src/Site/Resources/config/config.yml

settings:
    homepage:
        route:
            controller:     default.controller:indexAction
            pattern:        /
            # other Silex route parameters...
        view:
            title:          homepage.title
            metas:
                keywords:  "keyword, keyword, keyword"
    contact:
        route:
            pattern:        /contact
            method:         GET|POST
        view:
            template:       page/contact.html
            title:          contact.title

When no controller is given (eg: contact route), a default closure will be generated, returning the given template.

The configuration can be accessed in your twig template through the following syntax :

<h1>{{ app.config.get('homepage.view.title')|trans }}</h1>

As a convenience, you can use the shortcut to access the settings for the current matched route

<h1>{{ app.config.current('view.title')|trans }}</h1>

{# equivalent #}

<h1>{{ app.config.settings('homepage.view.title')|trans }}</h1>

The same applies inside a controller

public function indexAction(Request $request)
{
    $title = $this->container['config']->current('view.title', 'Default title');

    return $this->container['twig']->render('@site/Default/index.html');
}

The key

It is just a convention for settings your others application parameters.

# src/Site/Resources/config/config.yml
global:
    email:                  contact@localhost
    domain:                 localhost
    brand:                  brandname
    analytics_id:           UA-xxxxx
    facebook_url:           https://www.facebook.com/xxx
    linkedin_url:           https://www.linkedin.com/pub/xxx
    view:
        title:              " - default title suffix"
        metas:
            description:    "Silex app"

In a twig template:

# index.html

<title>{% block title %}{{ app.config.current('view.title') }}{% endblock %}{{ app.config.global('view.title')}}</title>

...

<a href="mailto:{{ app.config.global('email') }}">email me</a>

the settings and global keys are reserved

A section example

settings:
...

navigation:
    homepage:
        label:              homepage.label
        childs:
            contact:
                label:      contact.label

In a twig template:

{{ app.config.navigation('current.label') }}

Typical usecase using the bootstrap framework

{% import "@site/macro/navigation.html" as macros %}

<div id="navigation" class="navbar navbar-default navbar-fixed-top navbar-inverse shadow-bottom" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a href="{{ path('homepage') }}" class="navbar-brand" title="{{ app.config.global('brand')|trans }}">
        <span class="icon-logo"></span>
        <span class="suffix">{{ app.config.global('brand')|trans }}</span>
      </a>
    </div>
    <div id="scrollspy" class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
        {{ macros.menu(app.config.navigation('homepage.childs')) }}
      </ul>
      {% if app.locales %}
      <ul class="nav navbar-nav navbar-right">
        {% for locale in app.locales %}
        <li{% if app.request.get('_locale') == locale %} class="active"{% endif %}>
          <a hreflang="{{locale}}" href="{{path(app.request.get('_route'), {_locale: locale})}}">{{locale|upper}}</a>
        </li>
        {% endfor %}
      </ul>
      {% endif %}

    </div>
  </div>
</div>

Full config.yml example

global:
    email:                  contact@localhost
    domain:                 localhost
    brand:                  brand.name
    analytics_id:           UA-xxxxx
    facebook_url:           https://www.facebook.com/xxx
    linkedin_url:           https://www.linkedin.com/pub/xxx
    view:
        title:              view.title
        suffix:             view.title.suffix
        metas:
            description:    view.metas.description
settings:
    homepage:
        route:
            controller: default.controller:indexAction
            pattern:    /
        view:
            title:      home.title
            metas:
                keywords:    ~
                description: ~
    contact:
        route:
            controller: default.controller:contactAction
            pattern:    /contact
        view:
            title:      contact.title
    test:
        route:
            pattern:    /test
            i18n:       false
        view:
            template:   '@site/Default/test.html'

navigation:
    homepage:
        label:          home.label
        childs:
            contact:
                label:  contact.label
            test:
                label:  test.label

F/\Z-B 2014


All versions of configuration-silex-provider with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
silex/silex Version ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package faz-b/configuration-silex-provider contains the following files

Loading the files please wait ....