rcrowe / TwigBridge

Give the power of Twig to Laravel
MIT License
894 stars 168 forks source link

Problem with php 7 #271

Open matiux opened 8 years ago

matiux commented 8 years ago

Hi, I have an installation of laravel 4.2.17 on php 7 and "rcrowe/twigbridge": "0.6.*@dev" As you might imagine, I get this error

Cannot use 'String' as class name as it is reserved

from TwigBridge\Extension\Laravel\String class

I can't either update laravel or downgrade php

barryvdh commented 8 years ago

Does #269 fix it?

matiux commented 8 years ago

For now I have replaced Twig with blade since my template is very simple, but I think that renaming String in Str is the right way. Thanks

pinepain commented 8 years ago

@barryvdh that commit fixes problem. Can you tag it (both 0.6.x and 0.9.x) please?

shehi commented 8 years ago

@barryvdh , @rcrowe Still having this problem myself: just updated everything via composer today and it's broken (IDE-helper error below, during composer update):

Exception: Cannot instantiate Twig extension 'TwigBridge\Extension\Laravel\String': Class TwigBridge\Extension\Laravel\String does not exist

I am 100% sure it was fixed months ago. What has changed since then?! Wasn't that fix tagged as a release?

barryvdh commented 8 years ago

You have to update your config file.

shehi commented 8 years ago

I already have checked the readme of this package with my config file. Both providers and aliases are the same. Plus, the latest release here is of February this year. The mentioned fix came in late May. Are you sure it's included in the latest stable release?

barryvdh commented 8 years ago

Try the latest dev version then, and use the config for extensions from that version

shehi commented 8 years ago

Dear @barryvdh , is it that hard to have a tagged release, or is this package so messed up that the latest dev version is unreliable for a stable release? Now I feel very uneasy lol.

barryvdh commented 8 years ago

No it should work.

alrik11es commented 8 years ago

@shehi I've fixed as @barryvdh says.

/*
        |--------------------------------------------------------------------------
        | Extensions
        |--------------------------------------------------------------------------
        |
        | Enabled extensions.
        |
        | `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE.
        |
        */
        'enabled' => [
            'TwigBridge\Extension\Loader\Facades',
            'TwigBridge\Extension\Loader\Filters',
            'TwigBridge\Extension\Loader\Functions',

            'TwigBridge\Extension\Laravel\Auth',
            'TwigBridge\Extension\Laravel\Config',
            'TwigBridge\Extension\Laravel\Dump',
            'TwigBridge\Extension\Laravel\Input',
            'TwigBridge\Extension\Laravel\Session',
            'TwigBridge\Extension\Laravel\Str', // INSTEAD OF TwigBridge\Extension\Laravel\String
            'TwigBridge\Extension\Laravel\Translator',
            'TwigBridge\Extension\Laravel\Url',

            // 'TwigBridge\Extension\Laravel\Form',
            // 'TwigBridge\Extension\Laravel\Html',
            // 'TwigBridge\Extension\Laravel\Legacy\Facades',
        ],
coolynx commented 8 years ago

Just migrated an old project with Laravel v4.2.17 to another server with PHP7 using composer update as mentioned in https://github.com/rcrowe/TwigBridge/pull/269#issuecomment-229185888

composer require rcrowe/twigbridge:0.6.x-dev

Since I did not have a specific config file in app config directory, everything worked right away. It saved me hours of fiddling. 👍 💯 🍺