Git Product home page Git Product logo

yoyo-blade-app's People

Contributors

jreviews avatar khromov avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

khromov

yoyo-blade-app's Issues

Call to undefined method Illuminate\View\Compilers\BladeCompiler::components()

Hello,
As I amtrying to use Illuminate\View separately from Laravel, I am now using the solution from app/bootloader.php, and on a separate page without any additional logic it works great. Here's the code:

 <?php

 require_once 'vendor/autoload.php';

 use Clickfwd\Yoyo\Blade\Application;
 use Illuminate\Contracts\Foundation\Application as ApplicationContract;
 use Illuminate\Contracts\View\Factory as ViewFactory;
 use Jenssegers\Blade\Blade;

 $app = Application::getInstance();

 $app->bind(ApplicationContract::class, Application::class);

 $app->alias('view', ViewFactory::class);

 $blade = new Blade([__DIR__ . '/views'], __DIR__ . '/compiled', $app);

 $blade->compiler()->components([
     'components.alert' => 'alert'
 ]);

 $templateData = [
     'title' => 'Title',
     'text'  => 'This is my text!'
 ];

 echo $blade->render('page', $templateData);

But when I try putting it in a separate class I am getting Fatal error: Uncaught Error: Call to undefined method Illuminate\View\Compilers\BladeCompiler::components() :

 ...

 use Clickfwd\Yoyo\Blade\Application;
 use Illuminate\Contracts\Foundation\Application as ApplicationContract;
 use Illuminate\Contracts\View\Factory as ViewFactory;
 use Jenssegers\Blade\Blade as JenssegersBlade;

 class Blade
 {
     private JenssegersBlade $blade;

     public function __construct()
     {
         $app = Application::getInstance();

         $app->bind(ApplicationContract::class, Application::class);

         $app->alias('view', ViewFactory::class);

         $this->blade = new JenssegersBlade(
             [get_template_directory() . '/views'],
             get_template_directory() . '/compiled',
             $app
         );

         // Custom anonymous components
         $this->blade->compiler()->components([
             'components.media-image' => 'media-image'
         ]);
      }
 }

When I comment out $this->blade->compiler()->components part - everything works fine (except for the anonymous component).

Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.