laruence / php-lua

This extension embeds the lua interpreter and offers an OO-API to lua variables and functions.
http://pecl.php.net/package/lua
Other
149 stars 50 forks source link

Problem with laravel #9

Closed trompx closed 10 years ago

trompx commented 10 years ago

Hello laruence,

I'm pretty new to the linux world but I gave it a try at installing php-lua in order to play with some lua scripts in laravel.

I create a simple php file : $lua = new Lua(); $lua->assign("php_var", array(1=>1, 2, 3)); var_dump($lua->php_var);

If I launch it from linux terminal, I get the correct output.

When trying the same code inside a laravel class, I get the following message : "Class 'Lua' not found".

Do you know if there is some extra setup steps required to make it work with laravel ? I added extension=lua.so to php.ini file.

Thank you !

laruence commented 10 years ago

you can do the following steps to make sure it loaded correctly

  1. $ php -m | grep lua

if nothing output then means lua extension is not loaded.

  1. edit php.ini, set display_startup_errors=1

then you may find some warnings about why it wasn't loaded correctly

trompx commented 10 years ago

Just tried : php -m | grep lua and I get "lua" output so it loads correctly.

Basically I was trying to implement php lua as I could not figure it out how to pass a php object directly in an $redis->eval.

Exemple : $obj = new stdClass; $obj->attr1= $val1; $obj->attr2= $val2;

Then I was trying something like : $redis->eval( "local newobj = ".$obj." ");

But I was getting errors due to incorrect object format in lua. If this can helps someone, for this to work I had to correctly format it this way:

$redis->eval(" local newobj = {['attr1']= '".$attr1."', ['attr2']= '".$attr2."'} ");

But thanks for your input !

laruence commented 10 years ago

okey, thanks for feedback, I am going to close this. :)