cocur / slugify

Converts a string to a slug. Includes integrations for Symfony, Silex, Laravel, Zend Framework 2, Twig, Nette and Latte.
MIT License
2.89k stars 252 forks source link

Issue with usage, example doesnt work after installing with composer #302

Closed petrk94 closed 2 years ago

petrk94 commented 2 years ago

Hello, Im facing an, hopefully easy to solve issue, but I really dont know what the problem is. Im using the example of the github repository, the first one and installed it in the parent directory now using in the same directory the test.php file and its telling me

PHP Fatal error: Uncaught Error: Class 'Cocur\Slugify\Slugify' not found

Attached a screenshot, hopefully someone can help. Im using PHP 7.4

image

florianeckerstorfer commented 2 years ago

If you use this example with Composer do you have auto-loading enabled? More information: https://getcomposer.org/doc/01-basic-usage.md#autoloading

kktsvetkov commented 2 years ago

@petrk94 You need to include the composer beforehand

require '/vendor/autoload.php';

use Cocur\Slugify\Slugify;

$slugify = new Slugify();
echo $slugify->slugify('Hello World!'); // hello-world
petrk94 commented 2 years ago

Shame on me, thank you, I totally forgot that^^