Class 'Spatie\YamlFrontMatter\YamlFrontMatter' not found - php

I need help. I installed Yaml-front-matter via composer, everything was good. But if I use this class in my project, I get this very strange error. Why laravel doesn't see this class?
I do not find a solution with google.
I tried commands: php artisan optimize: clear, composer dump-autoload
but they don't help.
Thanks in advance.
screen to show the problem

Replace this
$document = YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html');
with this
$document = \Spatie\YamlFrontMatter\YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html');
It works.
Source: https://laracasts.com/discuss/channels/laravel/class-yamlfrontmatter-not-found-laravel-docker-composer

I was following a laracasts tutorial and ran into the same issue because I had missed they went through installing the package at the start of the video. I resolved it by just running:
composer require spatie/yaml-front-matter
The docs helped me out with resolving this, as there are a few other YAML related front-matter packages out there too.
https://github.com/spatie/yaml-front-matter.

Related

trying to run php artisan tinker returns error "file_exists(): Unable to find the wrapper "hoa" "

I'm trying to open tinker in a Laravel project, but when I run php artisan tinker I get this error:
ErrorException
file_exists(): Unable to find the wrapper "hoa" - did you forget to enable it when you configured PHP?
I can't find everything similar error online, I found only similar errors but with 'wrapper http' .
Does anyone have any suggestions? Thanks
Could this be due to custom code or a library you've imported?
I often find that if I add things to the ServiceProvider or Kernel, they run before many of the artisan commands, and if I've failed to perform the proper "if" checks first, it fails.
I suppose the question I would have in return would be; Is this a fresh Laravel install or have you got custom code and libraries running? I would check there, try removing libraries you've added, HOA from my searching doesn't appear to default to Laravel.
— Happy to revise my answer should more detail be provided
Solved with this command founded on github:
composer require psy/psysh:0.11.2 --dev

Trying to use a composer package in laravel

Im using Laravel 5.8.
Im trying to use the following package
https://packagist.org/packages/s1lentium/iptools
To install it i have run:
composer require s1lentium/iptools
Confirmed the require line is in the composer.json
"s1lentium/iptools": "^1.1"
and that the package is in "vendor/s1lentium/iptools/"
How can i reference it in the code (controller or even in a view)??
When I try to use the IP class Laravel cannot find it.
I've researched a lot and but without success. Hope anyone can lead me to the correct step.
Thanks!
Run composer dump-autoload
You must call the IP class with \IPTools\IP, or use it:
use IPTools\IP;
Hope it helps.

PHP PhantomJS - "use JonnyW\PhantomJs\Client;" Error?

I've installed PhantomJS and PHP-PhantomJS per the PHP-PhantomJS docs.
Per the PHP-PhantomJS docs, I have the following lines at the top of a php file:
use JonnyW\PhantomJs\Client;
$client = Client::getInstance();
When executing $client = Client::getInstance();, I get the error:
'JonnyW\PhantomJs\Client' not found
The installer has placed JonnyW\PhantomJs\Client here:
/Applications/myWebApp/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Client.php
The script that contains the "use" command is located here:
/Applications/myWebApp/application/controllers/myPHPscript.php
How can I modify the "use" command so as to locate the required "JonnyW\PhantomJs\Client" file?
I have looked at StackOverflow topics that appear similar but don't seem to provide the answer I need.
Thanks in advance to all for any info.
As noted, I followed the PHP-PhantomJS Docs in installing PhantomJS and PHP-PhantomJS. Per those docs, I used Composer to download and install everything. I'd never used Composer before. I learned that the framework I'm using, CodeIgniter, includes support for Composer. All I had to do was activate Composer support in the CodeIgniter config.php file, via the $config['composer_autoload'] setting.

Get Stream HttpSignatures\Context Not Found

I'm just a typical non professional PHP guy writing small apps for my website.
I am trying to install GetStream.io but because I don't know how to use composer (actually i tried, but i'm really not a terminal kind of person).
Anyway I couldn't create a autoloader as instructed by GetStream GitHub so I ended up creating my own autoloader.php using some codes pieced together from Stackoverflow.
My code
<?
function __autoload_namespaced_module($class) {
$path = str_replace('\\', '/', $class);
if (file_exists($file = ( $path . '.php'))) {
require_once($file);
}
}
spl_autoload_register();
spl_autoload_register('__autoload_namespaced_module');
?>
So yay i learnt something new today on autoload!!!
Until......
Fatal error: Class 'HttpSignatures\Context' not found in /GetStream/Stream/Signer.php on line 36
So now I know HttpSignatures\Context should be a php file in the home folder right, or something right but i check Git hub there's no such file....
Anyone encounter same problem and can install this SDK without composer?
Using composer to generate autoload files, or looking for dependencies can be a very difficult task for someone like me who are just using PHP to do simple apps.
I went through the steps in to use composer in MAC OS and it was complicated, very complicated and no idea what i was supposed to do following steps didn't help.
At last, I went online and find online PHP editors, and ended up with PHPStorm which gave me good syntax highlighter etc, and COMPOSER!
Now I finally know what composer is for and how it works.
TLDR: People who are having problem with composer, and have no idea what composer is, can try download PHPStorm for the 30days trial and just use it to generate the needed files.

Configuring MongoDB + doctrine in Symfony

I was trying to install MongoDB doctrine bundle as written in here
But when I ran the command
$ php bin/vendors install
It throws up the following error:
Fatal error: Call to undefined method
Doctrine\ODM\MongoDB\Configuration::setLoggerCallable()in
C:\wamp\www\Symfony\app\cache\dev\appDevDebugProjectContainer.php on line 245
I have followed the installation instructions to the word (which has not been much anyways...) and i have also double checked my installation... Is there something I am missing here?
Update : A similar problem is mentioned here, but even after following the answer there, i could not successfully configure DoctrineMongoDBBundle.
The latest changes in the Doctrine MongoDB repo have introduces this problem. To stick to a version before this happened, add this line to deps.lock:
doctrine-mongodb 5ccb18231218ce92c9d72295f69bebfe172ef5fb
Well, finally I managed to solve it by adding this to the deps file:
[DoctrineMongoDBBundle]
git=http://github.com/symfony/DoctrineMongoDBBundle.git
target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle
version=origin/2.0
** note the
version=**origin**/2.0
which is different from the previously suggested simple
version=2.0.0 or something similar...
I have a hunch that this problem occurs only on Windows, I hope someone could kindly confirm this.

Categories