TwigBridge icon indicating copy to clipboard operation
TwigBridge copied to clipboard

Problem with php 7

Open matiux opened this issue 8 years ago • 11 comments

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

matiux avatar May 24 '16 07:05 matiux

Does #269 fix it?

barryvdh avatar May 24 '16 09:05 barryvdh

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

matiux avatar May 24 '16 14:05 matiux

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

pinepain avatar Jul 04 '16 14:07 pinepain

@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?

shehi avatar Jul 08 '16 08:07 shehi

You have to update your config file.

barryvdh avatar Jul 08 '16 08:07 barryvdh

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?

shehi avatar Jul 08 '16 08:07 shehi

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

barryvdh avatar Jul 08 '16 08:07 barryvdh

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.

shehi avatar Jul 08 '16 08:07 shehi

No it should work.

barryvdh avatar Jul 08 '16 08:07 barryvdh

@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',
        ],

alrik11es avatar Aug 28 '16 10:08 alrik11es

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. 👍 💯 🍺

coolynx avatar Aug 30 '16 17:08 coolynx