Blade Template Engine - Jenssegers blade - template-engine

ı want to use blade template engine without laravel. I install this https://github.com/jenssegers/blade but don' t use this.
My index.php :
require 'vendor/autoload.php';
use jenssegers\blade;
$blade = new Blade('views', 'cache');
echo $blade->make('homepage', ['name' => 'John Doe']);
?>
ı have a error :
PHP Fatal error: Uncaught Error: Class 'jenssegers\blade' not found in /var/www/html/index.php:8
Stack trace:
0 {main} thrown in /var/www/html/index.php on line 8

For the record, this error is caused by the folder where the library was installed. They updated the composer.json for this reason. As a sidenote: psr-0 and psr-4 are broken, and it's one of the cause. I had the same problem with a couple of libraries.
Anyways. You can try this one: (one class, no dependency, 100% performance friendly, and it's updated).
https://github.com/EFTEC/BladeOne/
(Disclaimer: I am the author and it's free for the community)

Related

Issue with illuminate request when upgrading to laravel 6

I am getting the following code error after trying to upgrade to laravel 6 from 5.8, has anyone experienced this before?
Fatal error: Uncaught TypeError: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\Illuminate\Routing\RoutingServiceProvider.php on line 68 and defined in C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php:120
Stack trace:
#0 C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\Illuminate\Routing\RoutingServiceProvider.php(68): Illuminate\Routing\UrlGenerator->__construct(Object(Illuminate\Routing\RouteCollection), NULL, NULL)
#1 C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\Illuminate\Container\Container.php(799): Illuminate\Routing\RoutingServiceProvider->Illuminate\Routing\{closure}(Object(Illuminate\Foundation\Application), Array)
#2 C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\Illuminate\Container\Container.php(681): Illuminate\Container\Container->build(Object(Closure))
#3 C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\ in C:\xampp\htdocs\rebuild\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php on line 120
Similar issue is already listing on on Laravel repository and on Laracasts
It seems the problem is because of url() and asset() Helper functions used within in configuration files.
To resolve this error use config() or base_path or define absolute or relative paths in your config files instead of url() and assset() function for e.g
'cdn' => url('vendor/js/tinymce/tinymce.min.js'),
Changing it to
'cdn' => Config('app.url').'/vendor/js/tinymce/tinymce.min.js',
Change asset('home') to base_path('public/home'),
NOTE: You shouldn't use laravel dependencies inside config because the
config is loaded early in the request life cycle and things like
global helpers may not be available.
If you are using some dependencies in config file define them in .env files

Laravel not formatting 3rd party package

I've recently set up my Laravel 5.7 project with GIT. I did a clone onto a new computer and ran composer install. I keep getting a syntax error (T_CONSTANT_ENCAPSED_STRING).
I'm using a Upgraded version of Laravel 5.7(started at 5.1). Using the Bican Roles package to manage roles on the site.
I've tried reinstalling and uninstalling the package. Also tried wrapping it with double parentheses. (thats the part not formatting). all to no avail
//before rendering in app.blade.php
#role('admin')
// after rendering
<?php if (Auth::check() && Auth::user()->is'admin'): ?>
Errors I'm getting when trying to load the page.
syntax error, unexpected ''admin'' (T_CONSTANT_ENCAPSED_STRING) (View:
C:\wamp64\www\dashboard\resources\views\app.blade.php) (View:
C:\wamp64\www\dashboard\resources\views\app.blade.php) Previous
exceptions syntax error, unexpected ''admin''
(T_CONSTANT_ENCAPSED_STRING) (View:
C:\wamp64\www\dashboard\resources\views\app.blade.php) (0) syntax
error, unexpected ''admin'' (T_CONSTANT_ENCAPSED_STRING) (0)
This part leads to error: Auth::user()->is'admin'
It should be Auth::user()->is('admin'). You should check the code where the Blade directive #role is defined.

Laravel 5.3 Collective not installing

I'm learning how to work with forms but I got an error on the first try when I tried simple html code.
<form class="form" method="post" action="{{url('/painel/produtos/store')}}">
With this code I got this error:
MethodNotAllowedHttpException in RouteCollection.php line 218:
So I searched around and find out that people use this code instead
{{ Form::open(array('url' => '/painel/produtos/store')) }}
And I got a new error which is Class 'Form' not found so i searched and found that I would need Laravel Collective but when I try to install it it gives me this error:
[UnexpectedValueException]
Could not parse version constraint :5.3.0: Invalid version string ":5.3.0"
So I dont know what to do more.
Hello you can try this.
But the project has abandoned.
composer require "laravelcollective/html"::"^5.3.0"

Unable to find PHPUnit\Framework\Constraint\Constraint in Laravel BrowserKit package after upgrade to 5.4

I'm upgrading an old Laravel personal project from 5.2 to 5.4. The upgrade to 5.3 seems to have gone OK, but now I'm moving to 5.4 I've run into an issue.
The project used the old testing layer so I've installed the BrowserKit testing package to maintain backward compatibility. I also created the following base test case for the Browserkit tests:
<?php
namespace Tests;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class BrowserKitTestCase extends BaseTestCase
{
use CreatesApplication;
public $baseUrl = 'http://localhost';
}
The tests for the models, which use the normal test case, work fine, but when I run any of the tests that use the BrowserKit test case, I see the following error message:
PHP Fatal error: Class 'PHPUnit\Framework\Constraint\Constraint' not found in /home/matthew/Projects/myproject/vendor/laravel/browser-kit-testing/src/Constraints/PageConstraint.php on line 10
PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php:895
Stack trace:
#0 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(735): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')
#1 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(608): Illuminate\Container\Container->build('Illuminate\\Cont...')
#2 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(575): Illuminate\Container\Container->resolve('Illuminate\\Cont...')
#3 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(728): Illuminate\Container\Container->make('Illuminate\\Cont...')
#4 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExce in /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 895
Google hasn't been much use with this and the error message is not terribly illuminating. It seems to be something to do with the namespace because the class PHPUnit\Framework\Constraint\Constraint doesn't appear to exist, but I'm not sure how to resolve the issue. I've upgraded the version of PHPUnit to 5.7 as necessary, but that doesn't resolve the issue. Can anyone suggest what the issue might be?
EDIT: Just thought to try downgrading the version to 1.0 and that seems to solve the problem for now, so maybe version 2.0 is intended to work with PHPUnit 6? Still, hopefully this post will help someone out in future.
I ran into this today also.
Instead of downgrading laravel/browser-kit-testing from ~2.0 to ~1.0, I upgraded "phpunit/phpunit" from 5.7 to ~6.0 and that fixed the problem.
I agree that it is related to the PHPUnit namespaces. There is a commit to laravel/browser-kit-testing from May 25 with a title of "Use PHPUnit 6.0 namespaced classes."
Downgrading laravel/browser-kit-testing to 1.0 seemed to resolve the issue, so I'm guessing it's something to do with the namespaces for PHPUnit.
I think you need to instruct your test runner to use the bootstrap autoloader file containing PHPUnit class aliases.
try
phpunit --bootstrap bootstrap/autoload_test.php
If you are using a phpunit.xml configuration file, make sure your phpunit tag contains bootstrap="bootstrap/autoload_test.php" amongst your other set options, like the following:
<phpunit bootstrap="bootstrap/autoload_test.php">
You can instruct your test runner to read your phpunit.xml like so:
phpunit --configuration phpunit.xml

Class log does not exist in F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php:738 Stack trace:

I ran config:cache in my Laravel 5.2 application and this error started showing up.
Fatal error: Uncaught ReflectionException: Class log does not exist in F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php:738 Stack trace: #0 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(738): ReflectionClass->__construct('log') #1 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(633): Illuminate\Container\Container->build('log', Array) #2 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(697): Illuminate\Container\Container->make('log', Array) #3 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(853): Illuminate\Foundation\Application->make('log') #4 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(808): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) #5 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(7 in F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 738
I looked for many solutions. Nothing worked for me.
My .env file does not have any spaces
I deleted extra packages from my composer.json and ran composer update.
I ran php artisan clear compiled many times.
I looked for errors in my files but could not find any.
I also enabled the mysql extension since I found it somewhere. Then I did a fresh checkout of Laravel 5.2 and now the error is like this.
So, it's not a problem of any config file of mine. Its something else. Any of you have any idea?
Ok , so I solved it. Looks liek I had multiple issues.
In my fresh check out of laravel 5.2, where I was finding error about not having vendor/autoload.php file, I ran in the root directory in command window,
'composer update --no-scripts' , then 'composer update'. That solved the issue.
I also had to enable my mysql extension by editing php.ini file.
Finally, in my existing project, I actually found a problem in config/app.php. I missed a ',' somewhere. And people, laravel is a disgusting debugger. I miss my cakephp more.
It's a laravel 5 issue. Better to use laravel 4 still
Run this command:
php artisan dump-autoload
then composer update

Resources