Skip to content
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

Bump illuminate/support to 5.5 #1962

Closed
wants to merge 1 commit into from
Closed

Bump illuminate/support to 5.5 #1962

wants to merge 1 commit into from

Conversation

Log1x
Copy link
Member

@Log1x Log1x commented Aug 30, 2017

Some new goodies with the release of Laravel 5.5

@Log1x
Copy link
Member Author

Log1x commented Sep 5, 2017

@switch seems to work as intended as well as everything else stock but I seem to get an error with trying to use the new Custom If Statements.

$sage = sage('blade')->compiler();

/**
 * Create @test() Blade directive
 */
$sage->if('test', function () {
    return true;
});
@test 
   Hello
@endtest

results in:

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getEngineResolver() on null in /mnt/d/Development/web/sites/flux/web/app/themes/flux/vendor/illuminate/support/Facades/Blade.php on line 17

@patram1121
Copy link

The bump to 5.5 cased issues for my current project. In the following blade template, the last @php (right before $link) did not convert to <?php in the blade cache.

Note sure if this is a 5.5 issue or there is a change I need to make with my code to make it compatible.

    @if (have_rows('acf_repeater))
      @php
        $count = 1
      @endphp
      <div class="col-sm-3">
          @while (have_rows('acf_repeater')) @php(the_row())
            @php
              $link = sanitize_title($title);
            @endphp

Was able to workaround by forcing 5.4 in composer:

"illuminate/support": "~5.4.0",

@Log1x
Copy link
Member Author

Log1x commented Sep 5, 2017

Hmm. I did some testing and came across the same issue. It appears to be a problem with the shorthand PHP directive. I don't really understand what is causing it though. In some cases, it works just fine, but in others, not.

@webstractions
Copy link

webstractions commented Sep 22, 2017

@patram1121 I think you need a closing @endphp on the previous line:

@while (have_rows('acf_repeater')) @php(the_row()) @endphp

And FWIW, using this blade feature frequently may be a signal that you have too much logic embedded within your template. See Blade Docs

@webstractions
Copy link

@Log1x I am pretty sure there isn't an $app container in Sage. Thus the error. The if() method is running thru the Blade Facade and is trying to access $app['view'] which doesn't exist.

   /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return static::$app['view']->getEngineResolver()->resolve('blade')->getCompiler();
    }

@webstractions
Copy link

Just dawned on me about the other Sage components, sage-installer and sage-lib, which also need to be bumped up to 5.5 as well. They are at ~5.4 for Illuminate dependencies for Console, Filesystem, Config, and wait for it, View.

Those two packages need to be updated for this PR to play nice.

@Log1x
Copy link
Member Author

Log1x commented Sep 23, 2017

I'll give that a shot and do some testing and if all is well I'll do a PR over that way too so we can hopefully get this bumped.

@webstractions
Copy link

Sounds like a plan. Pretty sure that won't solve the custom if() statement though. You and @QWp6t talked about the App Container in #1932, which would fix this.

@webstractions
Copy link

@Log1x I have a 5.5 install running with no problems so far. Upgrading across the board (lib, installer, sage) doesn't have any ill effects.

The if() Blade directive is a sticky point. I am getting the same error that you did. In order to get around that, you have to install the complete Laravel package and create an App container. That would be going to far for what Sage is meant to be.

Coincidentally, this is not the first time something like this has come up (ie: cherry-picking Illuminate components). Take a look at Matt Stauffer's Torch. They have been trying to get Artisan support to work without downloading the entire package as well.

This just won't work without Illuminate\Foundation, which doesn't have composer.json to install from. And weirdly, Laravel Lumen has it's own version of Artisan piecemealed together and is kind of flakey. Seems they couldn't get around that either.

@webstractions
Copy link

@Log1x I found a workaround for getting the Blade if() method to work!

In setup.php add the following to the Sage Setup options where the singletons for assets and Blade are being bound to the container.

    // Set the Facade application container to the Sage Container
    \Illuminate\Support\Facades\Facade::setFacadeApplication(sage());

This not only fixes the if() method, but should allow us to use facades as well. The only thing missing is the AliasLoader, which is part of Illuminate\Foundation.

retlehs added a commit that referenced this pull request Apr 25, 2018
@retlehs retlehs mentioned this pull request Apr 25, 2018
oxyc added a commit to generoi/sage that referenced this pull request Jun 27, 2018

Verified

This commit was signed with the committer’s verified signature. The key has expired.
* roots/master: (41 commits)
  Add uglifyjs plugin (roots#2070)
  Add missing trailing commas in 2f51b51
  Run autoprefixer before minification
  Enable source comments in Sass
  Fix travis CI build error (missing trailing comma)
  Tweaked SVGO settings
  Make template() compatible with wp admin
  9.0.1
  Update to Bootstrap 4.1.1
  Remove useless whitespace
  Auto-detect  scheme
  Close roots#2028 - Increase priority on comments_template filter
  Remove Font Awesome reference [ci skip]
  Bump sage-lib
  Close roots#1962 - Bump to Laravel 5.6
  Remove php blade shorthand
  Stable vs dev install messaging, ref roots/docs#140 [ci skip]
  Update some dependencies
  Update CHANGELOG [ci skip]
  Bootstrap 4.1.0
  ...
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.

None yet

3 participants