Superleansilexplate Update v3

Some news from the Superleansilexplate:

  • v3 now uses symfony3 components
    Silex 1.3 supports symfony3 so lets use it :)
    Note: as symfony3 doesnt support php5.4 anymore, we dont either!
  • new ConsoleServiceProvider
    the one from knplabs that was used before seems to be unmaintained and wasnt matching the dependencies anymore.
    So i decided to take it over and renew it a bit. Check it out!
  • Docker support
    I started to use Docker as dev enviroment for my projects, so i added dev & prod Docker support.
    For the sake of simplicity it uses a single container with Apache and PHP7.
    If you have Docker and docker-compose on your machine just spin it up with docker-compose up and check on localhost:8088.

Continue reading “Superleansilexplate Update v3”

PHP package generators

For creating PHP packages several best practices has been established, like composer support (ofc) and putting the package on packagist, travis integration, directory organisation, tests, documentation and so on.
For further information i recommend these slides https://laravel-news.com/2015/08/hannes-van-de-vreken-package-development-slides/ which describe the situation very well.

And as we are all lazy, we like generators that scaffold a basic php package layout and luckily there are several out there.
They all differ a bit, so pick your favorite.
Continue reading “PHP package generators”

Using forks with composer – late night edition

Using your forks of certain packages with composer is actually pretty easy:
Add the repo of the fork to the repositories block of your composer.json, you might need to change the version to f.e dev-master and thats it. Great. Actually.

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ivoba/SomeBundle.log"
        }
    ]

But there are some traps, especially when you are mentally already weekend bound:

When working in a team, take care that you dont add your fork as a private repo.
This happens when you use the @ notation like ‘git@github.com‘. Its tempting because it will be the clone url on github when you are logged in, which is very likely.
If you do so your team mates will get errors like this:

Failed to execute git clone --no-checkout 'git@github.com:ivoba/SomeBundle.git' [...] && git remote add composer 'git@github.com:ivoba/SomeBundle.git' && git fetch composer

Continue reading “Using forks with composer – late night edition”

Symfony and named ParamConverters

Symfony’s ParamConverter is a common way to transform some GET param to an entity before your controllers action.
This happens most of the time via type hinting and priority detection kinda magic in the background.
But as magic is often obscure sometimes you need a bit of explicitness.

F.e. when you have more and different ParamConverter per entity you want to name them explicitly.
Then you can use named ParamConverters.

In the documentation this issue is a bit fragmented, so here is the compact version:
Continue reading “Symfony and named ParamConverters”

Enable Twig-Extensions in Silex revisited

As of 2014 things have changed improved a lot in the Symfony / Silex world, compared to 2011, when i first blogged about twig extensions in Silex.
Things got more easy, yay!

As Composer appeared, installation and autoloading is a breeze nowadays.
I presume here, that you have installed your Silex project via composer.
If so, you can install the twig extensions like this:
Continue reading “Enable Twig-Extensions in Silex revisited”

SilverStripe LinkField addon

Alright folks, so here is the SilverStripe addon of the month:
https://github.com/sheadawson/silverstripe-linkable

Its the missing LinkField, you might look for.
There are some more addons for a LinkField out there, but this one is the best.
No wonder, the author is SilverStripe employee.

It features:

  • external links
  • link validation
  • link a page from your site
  • link a file from your assets
  • oEmbed links
  • the addon is translated, currently only for german, but add your own, its easy!

Continue reading “SilverStripe LinkField addon”

Rename admin menu items in SilverStripe

SilverStripe 3.0.x cheap trick of the week:

If you want to rename a menu item in the SilverStripe Admin Area, because f.e. you find “Security” or “Sicherheit”(since we are german ;)) a too harsh wording and you prefer “Members” or “Benutzer”:
simply override the translation!

Add a lang folder in your project folder and add the language file:
de.yml or en.yml and place your wording:

de:
  SecurityAdmin:
    MENUTITLE: Benutzer

Continue reading “Rename admin menu items in SilverStripe”

SilverStripe speed up Portfolio Sites with Static Publisher

A common site type that we build are portfolio pages
which mostly get filled once in the beginning and then only periodically, rather rarely.
They also have almost never User interaction from the Frontend.

So we consider them as almost “readonly” sites.

These sites you can easily speed up “dramatically” with the SilverStripe builtin StaticPublisher.
The tweaks you need for this are moderate to easy.

You can read the Docs to get a glimpse of what is possible.
I will just describe the basic setup to make a site static.
Continue reading “SilverStripe speed up Portfolio Sites with Static Publisher”