How to install 'OAuth' for PHP



  • Ok so I am progressing...
    I have installed PHP Version 5.6.8 and wish to use the PHP OAuth Extention to use the Twitter API but it says Class 'OAuth' not found.

    I'm new to Linux so unsure what command I need to type in to install it.

    Can anyone help please?


  • administrators

    Hi @Brian-Moreau, OAuth in PHP is supplied by the PECL package. Can you try installing it with the following commands:

    opkg update
    opkg install php5-pecl
    


  • Unknown package 'php5-pecl'
    
    root@Omega-2774:/# opkg update
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base/Packages.gz.
    Updated list of available packages in /var/opkg-lists/chaos_calmer_base.
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base/Packages.sig.
    Signature check passed.
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/Packages.gz.
    Updated list of available packages in /var/opkg-lists/chaos_calmer_packages.
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/Packages.sig.
    Signature check passed.
    root@Omega-2774:/# opkg install php5-pecl
    Unknown package 'php5-pecl'.
    Collected errors:
     * opkg_install_cmd: Cannot install package php5-pecl.
    root@Omega-2774:/#
    


  • Ok so I ran an 'opkg list' command and got listed 100's of packages.
    PECL is not there...
    Another forum suggested I might need PEAR?
    This is a list of most of the PHP packages...

    php5-mod-calendar - 5.6.8-1 - Calendar shared module
    php5-mod-ctype - 5.6.8-1 - Ctype shared module
    php5-mod-curl - 5.6.8-1 - cURL shared module
    php5-mod-dom - 5.6.8-1 - DOM shared module
    php5-mod-exif - 5.6.8-1 - EXIF shared module
    php5-mod-fileinfo - 5.6.8-1 - Fileinfo shared module
    php5-mod-ftp - 5.6.8-1 - FTP shared module
    php5-mod-gd - 5.6.8-1 - GD graphics shared module
    php5-mod-gettext - 5.6.8-1 - Gettext shared module
    php5-mod-gmp - 5.6.8-1 - GMP shared module
    php5-mod-hash - 5.6.8-1 - Hash shared module
    php5-mod-iconv - 5.6.8-1 - iConv shared module
    php5-mod-json - 5.6.8-1 - JSON shared module
    php5-mod-ldap - 5.6.8-1 - LDAP shared module
    php5-mod-mbstring - 5.6.8-1 - MBString shared module
    php5-mod-mcrypt - 5.6.8-1 - Mcrypt shared module
    php5-mod-mysql - 5.6.8-1 - MySQL shared module
    php5-mod-mysqli - 5.6.8-1 - MySQL Improved Extension shared module
    php5-mod-openssl - 5.6.8-1 - OpenSSL shared module
    php5-mod-pcntl - 5.6.8-1 - PCNTL shared module
    php5-mod-pdo - 5.6.8-1 - PHP Data Objects shared module
    php5-mod-pdo-mysql - 5.6.8-1 - PDO driver for MySQL shared module
    php5-mod-pdo-pgsql - 5.6.8-1 - PDO driver for PostgreSQL shared module
    php5-mod-pdo-sqlite - 5.6.8-1 - PDO driver for SQLite 3.x shared module
    php5-mod-pgsql - 5.6.8-1 - PostgreSQL shared module
    php5-mod-session - 5.6.8-1 - Session shared module
    php5-mod-shmop - 5.6.8-1 - Shared Memory shared module
    php5-mod-simplexml - 5.6.8-1 - SimpleXML shared module
    php5-mod-soap - 5.6.8-1 - SOAP shared module
    php5-mod-sockets - 5.6.8-1 - Sockets shared module
    php5-mod-sqlite3 - 5.6.8-1 - SQLite3 shared module
    php5-mod-sysvmsg - 5.6.8-1 - System V messages shared module
    php5-mod-sysvsem - 5.6.8-1 - System V shared memory shared module
    php5-mod-sysvshm - 5.6.8-1 - System V semaphore shared module
    php5-mod-tokenizer - 5.6.8-1 - Tokenizer shared module
    php5-mod-xml - 5.6.8-1 - XML shared module
    php5-mod-xmlreader - 5.6.8-1 - XMLReader shared module
    php5-mod-xmlwriter - 5.6.8-1 - XMLWriter shared module
    php5-mod-zip - 5.6.8-1 - ZIP shared module
    

  • administrators

    @Brian-Moreau They might have removed the package from the latest build. Are you familiar with the cross compile environment? You should be able to compile the php5-pecl package with the following make file:

    #
    # Copyright (C) 2011-2014 OpenWrt.org
    #
    # This is free software, licensed under the GNU General Public License v2.
    # See /LICENSE for more information.
    #
    
    define Package/php5-pecl/Default
      SUBMENU:=PHP
      SECTION:=lang
      CATEGORY:=Languages
      URL:=http://pecl.php.net/
      MAINTAINER:=Michael Heimpold <mhei@heimpold.de>
      DEPENDS:=php5
    endef
    
    define Build/Configure
            ( cd $(PKG_BUILD_DIR); $(STAGING_DIR_HOST)/usr/bin/phpize )
            $(Build/Configure/Default)
    endef
    
    CONFIGURE_ARGS+= \
            --with-php-config=$(STAGING_DIR_HOST)/usr/bin/php-config
    
    define PECLPackage
    
      define Package/php5-pecl-$(1)
        $(call Package/php5-pecl/Default)
        TITLE:=$(2)
    
        ifneq ($(3),)
          DEPENDS+=$(3)
        endif
      endef
    
      define Package/php5-pecl-$(1)/install
            $(INSTALL_DIR) $$(1)/usr/lib/php
            $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$(subst -,_,$(1)).so $$(1)/usr/lib/php/
            $(INSTALL_DIR) $$(1)/etc/php5
        ifeq ($(4),zend)
            echo "zend_extension=/usr/lib/php/$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
        else
            echo "extension=$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
        endif
      endef
    
    endef
    


  • Thanks for that Boken Lin
    I assume I have to save the above code as a file?, of type? somewhere? on the device then run it with MAKE?
    Sorry I really know nothing about Linux or OpenWtr


  • administrators

    @Brian-Moreau You first need to set up a cross-compile environment: https://wiki.onion.io/Tutorials/Cross-Compile. Then you will need to go into the feeds directory, and create a directory there. Inside the directory, you will put the Makefile. Then when you go to compile the package, you will use the make menuconfig tool to select the php5-pecl package for compilation. From there, you will have the choice to build it directly into a firmware or build it as a separate package that you can then install on your Omega.

    Hope this helps!



  • @Boken-Lin Thank you as your name is popping up all over the community with very good answers. I've tried to do as you suggested but not quite there yet. I'm trying to achieve the same here to install peel which seems to need the cross compile. I made it to the step make menuconfig and am able to set the initial options (Target system, subtarget, Target profile). Then it becomes unclear.

    I've create the folder php5-pecl in the feeds directory. Inside I've created the Makefile.
    But I can find the php5-pecl in the make menuconfig options.

    Any tips or idea's ...?


  • administrators

    @Danny-van-der-Sluijs Can you post the content of your Makefile? I believe there's a configure in there that allows you to set which category you will be placing the package under.



  • Hi Sorry I am still totally lost...
    I don't seem to be able to run the first command to setup the Cross-Compile Environment.

    If I type ....
    $ apt-get install -y subversion build-essential libncurses5-dev zlib1g-dev gawk flex quilt git-core unzip libssl-dev
    I get $ not found, or if I just start command with apt-get .... I get apt-get not found error.

    I have tried this from both the control panel command line interface and the serial interface.
    What is the $ at the beginning of the commands and why is my device not recognising it?


  • administrators

    Hi @Brian-Moreau, It seems that you are trying to setup the cross-compile environment on the Omega. You need to set it up on a Linux computer. The cross-compile environment is an environment that allows you to compile source code to Omega-specific binary. Since the Omega itself doesn't have a huge amount of computational resource, it is usually done on a desktop (or laptop) computer.

    Do you know how to setup a virtual machine? We can walk you through the steps.



  • Hi again @Boken-Lin ,
    I very much appreciate your help and assistance in this since it is not strictly an Omega problem.
    Ok I am using WINXP PC and have in the past made dual boot so I should be able to manage to do that again but just wonder if you would recommend which virtual machine would be best for working with the Omega?



  • @Brian-Moreau I have had a lot of success running a KUbuntu 14.04 VM in a VirtualBox VM under Windows


  • administrators

    @Brian-Moreau Yeah, like @Kit-Bishop mentioned, one of the Ubuntu version is probably the easiest to get started. We've also got pre-compiled SDK for 64-bit Ubuntu.



  • Hi again @Broken-Lin
    Ok I made some progress...
    I installed KUbuntu on another computer.
    I have followed steps 1 and 2 for setting up the Cross Compile Platform and all is good.
    I now have the following prompt..
    /openwrt t$

    I am now at Step 3: Update Feeds but unsure what to do?
    I typed cd feeds to go to the feeds directory but it says no such file or directory.

    Thanks in advance
    Brian



  • @Brian-Moreau Some small bits of clarification that may help:

    • There is no directory feeds - feeds is a script file in the directory scripts under your openwrt directory
    • The file feeds.conf.default that needs modifying referred to in Step 3 of the tutorial is in your openwrt directory
    • The command to be run as described in Step 3 i.e.:
      scripts/feeds update -a
      should be run from your openwrt directory.
      It runs the feeds script that is in the scripts directory.
    • All other commands covered in the tutorial should similarly just be run from the openwrt directory


  • @Boken-Lin said:

    Do you know how to setup a virtual machine? We can walk you through the steps.

    This would be great been thinking about doing this while I wait on my second Omega. Could you be so kind as to post the steps for setting up VM?



  • @Rudy-Trujillo First you will need to get and install a copy of VirtualBox. This can be found at: https://www.virtualbox.org/wiki/Downloads

    Then you will need an OS image to run on the VirtualBox - most commonly used for Omega work seems to be KUbuntu.

    There are two ways to do this:

    1. The hard way: download an ISO of the KUbuntu version you want (these can be found here: http://www.kubuntu.org/getkubuntu/). Then create a VM instance in VirtualBox that you install to from the ISO image - i.e. set the VM up to boot from the ISO image as a CD/DVD and follow the installation process. When that is complete, disconnect the VM from the ISO image and when you reboot the VM, you should be running the installed system.
    2. The easy way: Download a pre-installed VirtualBox VM image for the version you want. I would suggest the one that can be obtained from here: https://virtualboximages.com/Kubuntu+15.04+amd64+VirtualBox+VDI+Virtual+Computer
      Then just open it using VirtualBox and you will be running the pre-installed system.


  • @Rudy-Trujillo A PS to my previous message: some people prefer VMWare over VitualBox.
    A free copy of VMWare can be found at: https://my.vmware.com/web/vmware/info?slug=desktop_end_user_computing/vmware_workstation/10_0
    The principle of VMWare is pretty much the same as VirtualBox
    I am less familiar with the availability of pre-installed VMWare images and you may have to do a google search for one.


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.