Welcome Guest, Not a member yet? Register   Sign In
Composer, php-diff and Class Not Found problems
#1

Hoping someone can point out the error of my ways. Haven't used composer very much, but it appears to have properly loaded the files, but I am still getting the dreaded "Class "DiffHelper" not found" error.
1) Installed the library with composer: "composer require jfcherng/php-diff"
2) Verified the files are there (/_site/vendor/jfcherng/php-diff/src/DiffHelper.php)
3) Added to the top of my controller: "use Jfcherng\Diff\DiffHelper;" (also tried "use DiffHelper;")
4) In my view file called: 

PHP Code:
<?php
 $changes 
DiffHelper::calculate($oldRecord[0]['comments'], $oldRecord[count($oldRecord)-1]['comments'], 'Unified');
 echo 
$changes;
 
?>

Ran the page and got the "Class not found" error! Feeling like I missed a step somewhere.

Thanks in advance!
Reply
#2

I tried installing this package. There were no problems.

Check it out.
- Use section must be specified after namespace
- file vendor/composer/autoload_psr4.php should contain an entry about the path to the package. (if not, use `composer dump-autoload` command)
Reply
#3

(This post was last modified: 11-09-2021, 11:10 AM by SoccerGuy3.)

(11-09-2021, 12:44 AM)iRedds Wrote: I tried installing this package. There were no problems.

Check it out.
- Use section must be specified after namespace
- file vendor/composer/autoload_psr4.php should contain an entry about the path to the package. (if not, use `composer dump-autoload` command)

The "Use" is after the namespace:
PHP Code:
<?php

namespace App\Controllers\Auction;

use 
App\Entities\User;

use 
DiffHelper

The psr4 file contains:
Code:
    'Jfcherng\\Utility\\' => array($vendorDir . '/jfcherng/php-color-output/src', $vendorDir . '/jfcherng/php-mb-string/src'),
    'Jfcherng\\Diff\\' => array($vendorDir . '/jfcherng/php-diff/src', $vendorDir . '/jfcherng/php-sequence-matcher/src'),

I think I am giving up on this. I found a javascript from google that does the same thing with zero hassle. Thanks for checking it out, but it just shouldn't be this difficult! LOL. Isn't that the point of composer?

Were the steps I used correct?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB