ausi/slug-generator

Attempted to load class "Normalizer" from the global namespace.

pegasus1982 opened this issue · 15 comments

I installed this package in symfony 4 project.

I followed the steps to generate slug.
But I got this error.
image

How can I solve this issue?

ausi commented

The error message indicates that the PHP intl extension is not installed or not activated.

Please check the intl section in your phpinfo to see if the extension is active.

Of course I activated php intl extension.

ausi commented

But the Normalizer class is still not available?

Can you please check if the Locale class is present in your PHP setup?
var_dump(class_exists('Locale'));

Let me check

it returns bool(true).

ausi commented

And var_dump(class_exists('Normalizer')); is false ?

No it is bool(true).

The weird thing is that this package works on windows, but my server was installed on ubuntu.
And I want it would work definitely.
But it doesn't work.

ausi commented

In the initial comment you posted the error message of a ClassNotFoundException which cannot happen if class_exists('Normalizer') returns true.

Are you sure you executed the class_exists() code in the same environment where the slug library shows this error?

Let me check

Well, it always returns true

ausi commented

Even if you put the var_dump(class_exists('Normalizer')); in the file vendor/ausi/slug-generator/src/SlugGenerator.php on line 79:

$text = \Normalizer::normalize($text, \Normalizer::FORM_C);

you get true but a ClassNotFoundException gets thrown on the next line?

ausi commented

@pegasus1982 any updates on this?

I uninstalled php and installed all from scratch.
And it worked now.