How to use Class from .so file of PHP extension in Controller ? I installed a PHP extension (.so file), after that ,I can use obj = new \AAA\BBB(); in pure PHP file .
Please help me how to use it in Controller of Laravel ?
new \AAA\BBB(); will not working for wrong Namespace.
Thank you very much.
What are you actually trying to do and load. What is the actual namespace.
step1.
pear install opendogs/mecab-beta
step2.
Test in PHP file.
<?php
$mecab = new \MeCab\Tagger();
$parsed = $mecab->parse('this is test');
var_dump($parsed);
?>
step1, step1 are all fine.
Problem is : how to use new \MeCab\Tagger(); in Laravel Controller ?
create a composer package (instead of using pear), and use composer to install it. Then it will show up in /vendor with the rest of your packages and what you wrote will work.
Did you try above leaving out the php tags, or appling a use statement:
It should work in a controller just like you did:
$mecab = new \MeCab\Tagger();
$parsed = $mecab->parse('this is test');
var_dump($parsed);
It`s a PHP extension written in C, how to create composer package, please help
Please sign in or create an account to participate in this conversation.