Closed mark8044 closed 3 years ago
Hi @mark8044, thanks for the kind words - yes, the library is stable and actively maintained. It would be great if you used Composer, but if you really can't, you can always download the library code and put it into your project directly.
Hi @mark8044, thanks for the kind words - yes, the library is stable and actively maintained. It would be great if you used Composer, but if you really can't, you can always download the library code and put it into your project directly.
Thats great to hear! Do you have an example of how I could use it?
I tried the following but its a total fail:
require_once(DIR . '/myincludes/shortcode/ShortcodeFacade.php');
use \Shortcode\ShortcodeFacade;
use \Shortcode\Shortcode\ShortcodeInterface;
$facade = new ShortcodeFacade();
$facade->addHandler('hello', function(ShortcodeInterface $s) {
return sprintf('Hello, %s!', $s->getParameter('name'));
});
$text = '
<div class="user">[hello name="Thomas"]</div>
<p>Your shortcodes are very good, keep it up!</p>
<div class="user">[hello name="Peter"]</div>
';
echo $facade->process($text);
You probably have to manually require
each (used) class/file or implement some sort of autoloader for this library yourself.
@mark8044 yes, @jdreesen is right - one of the (loads of) benefits of Composer is that you get an autoloader for free. If you want to use the library without it, you need to autoload classes yourself, either by manually require()
ing the files or registering your own autoloader through spl_autoload_register()
.
You can't just load the ShortcodeFacade
because it requires other classes, but you're pretty close - please either make your own autoloader or just keep loading the missing classes manually.
...or you can use Composer and get the autoloader and all of the other goodies for free. :smile: The choice is yours!
@mark8044 I'm closing this issue as we've answered your question. Feel free to open another one if there is anything else we can help you with.
Really need a BBCode parser and glad to have found this one that looks actively supported? But I have no way of using composer. Any easy way to still use this?
Thanks!!