jbowens / jBBCode

A lightweight but extensible BBCode parser
http://jbbcode.com
MIT License
164 stars 32 forks source link

Class 'JBBCode\Parser' not found in Laravel #11

Closed SaintPeter closed 10 years ago

SaintPeter commented 10 years ago

I installed the (newly refreshed) v1.2.0 of JBBCode from packagist in my instance of Laravel via composer. It appeared to install correctly, but I am unable to instantiate the parser (or any other) of the classes in the JBBCode namespace.

My vendor/composer/autoload_namespaces.php file appears correct:

    return array(
        'JBBCode' => array($vendorDir . '/jbbcode/jbbcode'),
    );

My instantiation in a controller is just:

    $parser = new JBBCode\Parser();

I consistently get an error of "Class 'JBBCode\Parser' not found"

I don't appear to be doing anything else weird or wrong. Have you tested this against a Laravel install?

SaintPeter commented 10 years ago

I had to include this in my /start/global.php:

require app_path().'/vendor/autoload.php';
markhughes commented 7 years ago

This comes up in google search results, so just letting people know you don't have to do that. Just use the namespaces like so:

        $parser = new \JBBCode\Parser();
        $parser->addCodeDefinitionSet(new \JBBCode\DefaultCodeDefinitionSet());