philonl / laravel-blade Goto Github PK
View Code? Open in Web Editor NEWUse the simple and yet powerful Laravel Blade templating engine as a standalone component.
Use the simple and yet powerful Laravel Blade templating engine as a standalone component.
When there is an undifined variable in blade file it throws an error that is director to cache file rather then the blade file itself. Here is example
Notice: Undefined variable: post in /app/cache/5952d10558fadf03e7e98e30ca3073c9 on line 19
Hi,
I tried to use extend
like so
Blade::extend(function($value)
{
return preg_replace('/(\s_)@(break|continue)(\s_)/', '$1$3', $value);
});
I get
Call to undefined method Philo\Blade\Blade::extend()
Thank you.
Because we can use @Inject then.
Hi !,
I did a composer require for this package. Then I started getting below error in my app.
["message"]=> string(48) "Call to a member function make() on a non-object"
["file"]=> string(81) "/path/to/project/vendor/illuminate/support/Illuminate/Support/helpers.php"
["line"]=> int(33) }
Below is my composer require output.
> composer require philo/laravel-blade 2.*
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing illuminate/support (v4.2.9)
Loading from cache
- Installing illuminate/filesystem (v4.2.9)
Downloading: 100%
- Installing illuminate/container (v4.2.9)
Loading from cache
- Installing illuminate/events (v4.2.9)
Loading from cache
- Installing illuminate/view (v4.2.9)
Downloading: 100%
- Installing philo/laravel-blade (v2.1)
Downloading: 100%
Writing lock file
Generating autoload files
I'm getting this error even though I didn't even start using this library, why is that?
Hi, I'm trying to use the $this variable in a view using the Blade layout. I have already made a with('this', $viewObject)->
calling and when I make a var_dump of the $this variable it works just fine and says that it's the view object. But the moment I try to call any method inside it, launches the error Call to undefined method Illuminate\View\Engines\CompilerEngine::methodName()
Am I doing anything wrong?
I want to get a singleton instance, that is; I instantiate the Blade Class once (automatically) and then use a static function like Blade::instance() to get the object instantiated already. In this way, I won't have to worry about new Objects being made everytime.
F3 uses the following function to get the desired effect. Can I somehow manage to do the same here?
static function instance() {
if (!Registry::exists($class=get_called_class())) {
$ref=new Reflectionclass($class);
$args=func_get_args();
Registry::set($class,
$args?$ref->newinstanceargs($args):new $class);
}
return Registry::get($class);
}
There were a few major additions to loops in L5.3, any chance to get them in your package? Thanks a lot!
I have copied to Windows from Mac when running the browser, error message
include(/opt/lampp/htdocs/ecommerce/app/functions/../../bootstrap/cache/3c00fb5c6cc02832d7d184095ad221d65e528e2d.php): failed to open stream: No such file or directory (View: /opt/lampp/htdocs/ecommerce/resources/views/errors/404.blade.php)
Pls, give me the solution?
Hello,
Thanks for this amazing thing so that I can use it outside of Laravel.
In development, when I change the blade file and reload the browser, the changes don't immediately show up until I delete all cache files.
How can I do the immediate change for this?
Thanks!
Hey, thanks for providing such a useful library. I do have a small issue i have encountered. I have a directory structure as follows:
views
---- admin
------ user.blade.php
I am trying to load the view file using the code below :
echo $blade->view()->make('admin.user');
Unfortunately, this does not seem to be working. The view file is not loaded. Do you have any ideas?
Cheers
Can you please tag a release, so this can be installed via composer properly. Thanks!
Hi,
Any plans to align to illuminate/view 5.0?
Hi, first of all thanks for your great package.
I'm using v3.* and when a run my project I get this error:
Fatal error: Call to undefined method Illuminate\Container\Container::bindShared() in C:\xampp\htdocs\superlogros\vendor\philo\laravel-blade\src\Blade.php on line 70
This is where I autoload the package
/sys/sys.php
require 'vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as Capsule;
use Philo\Blade\Blade;
$database = new Capsule();
$database->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'database' => '...',
'username' => '...',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'web',
]);
$database->setAsGlobal();
$database->bootEloquent();
$views = '../views';
$cache = '../cache';
$blade = new Blade($views, $cache);
And this is my test file: /test.php
require 'sys/sys.php';
echo $blade->view()->make('index')->render();
What I'm doing wrong?
Pd: Sorry for grammar mistakes, my English level is still low ๐
Why 4.1.* constraint have been used? For PHP 5.3 BC?
So can you begin i.e. 2.0 branch with 4.* constraint?
It should be safe for those consumers that install this library on 5.3 projects with 1.* version constraint.
how to minify HTML/CSS/JS if i use your library??
any help will be great for me.
Thanks in advance..
...when you need half of the framework for it?
Version 2.3, ported from Laravel 5.0, should be marked as 3.0 since it is not backwards compatible.
Anyone pulling in "~2.*" will have a broken project on their hands.
Thanks ~
It doesn't work because the global function app() doesn't exist, put this somewhere before the Blade class is instantiated to make it work.
use Illuminate\Container\Container;
$container = new Container();
Container::setInstance($container);
$container = Container::getInstance();
if (! function_exists('app')) {
/**
* Get the available container instance.
*
* @param string $make
* @param array $parameters
* @return mixed|\Illuminate\Foundation\Application
*/
function app($make = null, $parameters = [])
{
if (is_null($make)) {
return Container::getInstance();
}
return Container::getInstance()->make($make, $parameters);
}
}
Now injecting into the views works (it's basically instantiating a class of your choice using the Container) and you can also use this DI container for your app.
I use and run on my pc, it work very well, but when i upload my project in Centos Vps, cache file is not create in cache folder. Help me resolve this issue. Thanks all
I came across a problem today.
Wanted to extend blade so I can assign variables in the templates them self but It gave me the following error : "Call to undefined method Illuminate\View\Factory::extend()"
Is there someone who knows how to fix this ?
Greets Wouter.
Does anybody now I can call the view composer ?
I try to run :
$this->blade->view()->composer('file');
Now I get this error :
Warning: Missing argument 2 for Illuminate\View\Factory::composer(), called in
How can I fix this ?
Line 45 in e26fe17
Hello,
i'm using this package in a WordPress Environment,
basically i'm trying to let blade control my output however when more than one package using this class exists the engine cannot recognize the file extensions of blade templates
any ideas why the package would fire this error?
Hello,
I cant get my router extend function working.
Now I am wondering if I am doing this correctly or not.
Could somebody help me please.
Here is the code :
view :
calling <p>@router('home')</p>
Outputted : <p><?php $router = new AltoRouter(); echo $router->generate(); ?>('home')</p>
blade extend :
$this->blade->getCompiler()->extend(function($view, $compiler)
{
$pattern = $compiler->createPlainMatcher('router');
$replace = '<?php $router = new AltoRouter(); echo $router->generate($3); ?>';
return preg_replace($pattern, $replace, $view);
});
as you would in laravel?
\Blade::setRawTags('{+', '+}');
Update:
I see you can do getCompiler() and do it that way, but regardless of the tags I put, my app is still escaping HTML when I'm trying to echo an html string.
Is there any chance to implement the new blade components X.
I need use the blade components like laravel 7 but I want continue using this awesome package.
I tried add other php packages like this: https://github.com/spatie/laravel-blade-x but I can't find the way to resolve it.
This one register a new service provider...
Sorry, I'm a little lost... Any ideas?
what level of compatibility with laravel 5.2? Did you have the opportunity to test?
thanks for the package,
i am using this package without laravel (in my mvc framework) , but when i am using persian characters in .blade files , character will convert to ?????? in compiled view file ! how can i set utf8 and solve the problem ?
Hello,
I've been using this for some time now and it has been working fine for me. I have a production and a development environment and using git branches for these.
Now suddenly I'm having issues with the blade cache files between these branches. How should these files be handled with git? Should the files be ignored og created directly on production or should I track them with git from the development?
Also when are these files regenerated in Blade?
Thanks in advance
After a composer update, every pages are broken, returning the following exception message :
( ! ) Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Cannot end a section without first starting one.' in /home/web/core/vendor/illuminate/view/Factory.php on line 564
( ! ) InvalidArgumentException: Cannot end a section without first starting one. in /home/web/core/vendor/illuminate/view/Factory.php on line 564
I suppose it's a regression issue introduced with the 5.2 version of illuminate packages ?
Hi, when i pass an object to a view, properties are present, however, i can't use methods!
Any idea about this?!
is it possible to use custom blade Blade::directive?? if yes, wii you give me a demo ??
The issue is with PHP 8, when trying to create Blade object and passing the values
But I got this error: Deprecated: Required parameter $cachePath follows optional parameter $viewPaths
of course because of PHP 8
So can you at least make $cachePath
nullable or make $viewPaths
required too
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.