Jump to content

Help, how do I use bricklets with PHP?


Recommended Posts

Geschrieben

Ive been using parts with Python but now want to start playing with PHP. 

When I run the command "pear install Tinkerforge.tgz" I get this error...

 

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Ignoring installed package __uri/Tinkerforge

 

So does this mean I need to install MySql in order to use PHP with the bricks/bricklets?

Geschrieben

No, the PHP bindings don't require MySQL. The only requirement is that your PHP has the bcmath extension enabled.

 

It seems to me that there's something wrong with either your PEAR or your PHP installation that leads to those errors about MySQL.

 

Actually the "Ignoring installed package __uri/Tinkerforge" line tells you that the Tinkerforge PEAR package is already installed. At least PEAR thinks so.

 

Try running

 

pear list -c __uri

 

to see what packages are already installed on the __uri channel. The Tinkerforge should be there. Then the PHP examples from the Tinkerforge PHP bindings zip should already work.

Geschrieben

I reinstalled MySQL and got it working. 

This is the output I get with that command...

 

Installed packages, channel __uri:

==================================

Package    Version State

Tinkerforge 1.0.11  stable

 

Now, when I open the page ExampleCallback.php which I have placed on my Apache server, it does nothing but display a blank page.

 

My host, port, and uid are correct...

$host = 'localhost';

$port = 4223;

$uid = '5Jj'; // Change to your UID

 

I've played around with these settings within the PHP file...

require_once('Tinkerforge/IPConnection.php');

require_once('Tinkerforge/BrickletAmbientLight.php');

 

use Tinkerforge\IPConnection;

use Tinkerforge\BrickletAmbientLight;

 

I'm thinking my problem may be permissions or something?  or something to do with the ports?

 

I have run this command to set permissions...

find . -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;
Geschrieben

Before trying it in Apache you should try it on the command line with the php commandline tool.

 

Do other PEAR installed packages work within Apache? Maybe its a problem with your PEAR setup.

 

You could try to enable all the error reporting for PHP so that Apache shows possible errors. You should also have a look at the Apache logs for possible hints.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...