Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Jan 31, 2016

Issues when reinstall phpbrew on OS X EI Capitan

Annoying things coming one by one.

After update to EI Capitan, I found that all my configuration for linking phpbrew with system apache lost. Resolved quickly, but...

After did 'brew update' today, phpbrew poisoned by new version of icu4 installed by homebrew. It was built with 54, but now version is 56, so it always complained about could not find the so file...even when change a directory, just because the 'source ~/.phpbrew/bashrc' in my own .bashrc.

At last, I decided to CLEAN all this messed stuff up, via... rm -rf ~/.phpbrew.

And prepared to reinstall it, not be aware of what was waiting for me....

Issue#0 operation not permistted when 'sudo chmod -R oga+rw /usr/libexec/apache2'
  root cause: Apple's system integrity protection
  solution: reboot, cmd+r to enter repair mode, open terminal, execute 'csrutil disable; reboot'
  reference: http://stackoverflow.com/questions/32659348/operation-not-permitted-when-on-root-el-capitan-rootless-disabled

Issue#1 Cannot find OpenSSL's <evp.h>
  root cause: openssl header file missing
  solution: $phpbrew ...+openssl=/usr/local/opt/openssl
refernce: https://github.com/phpbrew/phpbrew/issues/612

Issue#2 Cannot find OpenSSL's libraries
  root cause: openssl lib path missing
  solution: $sudo ln -s /usr/local/opt/openssl /usr/lib/openssl
  reference: https://github.com/phpbrew/phpbrew/issues/418

Issue#3 Cannot locate header file libintl.h
  root cause: gettext header file missing
  solution: $brew link icu4c gettext --force
  refernce: https://github.com/phpbrew/phpbrew/issues/453

Issue#4 symbols not match when php build sis linking:
  Undefined symbols for architecture x86_64:
  "_PKCS5_PBKDF2_HMAC", referenced from:
      _zif_openssl_pbkdf2 in openssl.o
  "_TLSv1_1_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_1_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  root cause: ???
  solution: run following command before phpbrew install: $export LDFLAGS="/usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib"
  referenc: http://weaponsgradecode.com/2015/10/12/installing-php-5-6-14-with-phpbrew-and-homebrew-on-os-x-el-capitan/

Finally, my new php-5.6.17 was installed under phpbrew with the following command:
phpbrew install 5.6.17 +default +mysql +pdo +apxs2=/usr/sbin/apxs +dba +filter +gettext +iconv +mcrypt +openssl=/usr/local/opt/openssl +posix +session +soap +sqlite +gd -- --with-gd=shared --enable-gd-natf --with-jpeg-dir=/usr --with-png-dir=/usr

Final thought: it came to my mind at last that homebrew suggest similar method as LDFLAGS config when install some module like openssl. So it might be a compile flag setting which could solve the openssol <evp.h> issue....but anyways, I don't want to try that myself.

Oct 16, 2015

Install zmq extension to phpbrew

phpbrew doesn't (seems) support zmq in its official extension list.

Have to find a way around this issue.

Firstly, turn off phpbrew
  phpbrew off

Now using system php.

Next, upgrade system php to 5.6:
  sudo add-apt-repository ppa:ondrej/php5-5.6
  sudo apt-get update
  sudo apt-get install python-software-properties
  sudo apt-get update
  sudo apt-get install php5

Now, install zmq:
  sudo pecl install zmq-beta

After zmq.so created, copy it to the phpbrew directory:
  sudo cp /usr/lib/php5/20131226/zmq.so ~/.phpbrew/php/php-5.6.6/lib/php/extensions/no-debug-non-zts-20131226/zmq.so

Bingo! Now I can composer require react/zmq under my project!!

Links:
http://www.dev-metal.com/install-setup-php-5-6-ubuntu-14-04-lts/

Jun 1, 2015

Solved phpbrew problem with posix function not found

This morning apache complained to me that:

  posix_geteuid() function not found

So weird, because I installed this php version definitely with posix enabled, via phpbrew.

So I installed again:

sudo -s
phpbrew init -c config.yaml
phpbrew install 5.3.29 +dev (i have predefined a dev shortcut in the config file for convenience)
...
phpbrew switch 5.3.29
exit
sudo service apache2 restart

Not working....

So I decided to do it manually instead, guessing the config file not configuring phpbrew very fitting.


phpbrew install 5.3.29 +default +mysql +pdo +apxs2=/usr/bin/apxs2 +dba +filter +gettext +iconv +mcrypt +openssl +posix +session +soap +sqlite +gd -- \
--with-libdir=lib/x86_64-linux-gnu --with-gd=shared --enable-gd-natf --with-jpeg-dir=/usr --with-png-dir=/usr

This time the installed php version working.

So my guess is correct.

ps, the content in my config.yaml:

variants:
    dev:
        bcmath:
        bz2:
        calendar:
        cli:
        ctype:
        dba:
        dom:
        fileinfo:
        filter:
        gettext:
        ipc:
        iconv:
        json:
        mbregex:
        mbstring:
        mhash:
        mcrypt:
        mysql:
        openssl:
        pdo:
        posix:
        session:
        soap:
        sqlite:
        gd:
          - --with-libdir=lib/x86_64-linux-gnu
          - --with-gd=shared
          - --enable-gd-natf
          - --with-jpeg-dir=/usr
          - --with-png-dir=/usr
extensions:
    dev:
        xdebug: stable
        yaml: stable
        curl: stable
        gd: stable

Jan 9, 2015

解决 phpbrew gd 的 undefined symbol: php_gd_gdImageJpegCtx in Unknown on line 0

Issues coming one after one, started from the day I upgrade my machine from ubuntu 12.04 to 14.04.

Thanks to our ancient symfony 1.4 project, I had to ask phpbrew for php version 5.3.x, and then I got a problem with gd when project rebuild on the step of regenerating avatars.

It said in bloody color:

The image processing library GD is not enabled. See PHP Manual for installation instructions.

WTF?

I checked the extensions of current php:

  $phpbrew ext

Oh well, gd ext not enabled, so

  $phpbrew ext enable gd

However, it complained:
 
PHP Warning:  PHP Startup: Unable to load dynamic library '/home/htsg/.phpbrew/php/php-5.3.29/lib/php/extensions/no-debug-non-zts-20090626/gd.so' - /home/htsg/.phpbrew/php/php-5.3.29/lib/php/extensions/no-debug-non-zts-20090626/gd.so: undefined symbol: php_gd_gdImageJpegCtx in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/home/htsg/.phpbrew/php/php-5.3.29/lib/php/extensions/no-debug-non-zts-20090626/gd.so' - /home/htsg/.phpbrew/php/php-5.3.29/lib/php/extensions/no-debug-non-zts-20090626/gd.so: undefined symbol: php_gd_gdImageJpegCtx in Unknown on line 0
===> Enabling extension gd
gd extension is not installed. Suggestions:
$ phpbrew ext install gd

Damn it, how could it suggest to install an extension already installed, sth wrong with it definitely....

Googling time....... with painful tries...ruined my whole lovely friday morning....

When it turned to be hopeless, found a working solution:

$cd
$cd .phpbrew/build/php-5.3.29/ext/gd/
$make clean
$phpbrew ext install gd -- --with-libdir=lib/i386-linux-gnu --with-gd=shared --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr

This time it said install ok as before, but I saw gd in the enabled list when check extensions.

Thanks to this link for saving the rest of my Friday!






Dec 6, 2013

[Resolved] Eclipse 4.3.1 has no PHP perspective after PDT installed

Last night I installed Eclipse 4.3.1 on my iMac under ubuntu 13.10, all good till I found that no matter how I tried, Eclipse wouldn't show out the PHP perspective. The PHP perspective even did not exist in Window->Open Perspective->Other... dialogue.

This made me a bit crazy.

However, finally, here is the dramatic end of the story.

After struggling with uninstall/reinstall several versions of several plugins, and searched online, no luck though. But one thread made me thought about the permission of the path I installed Eclipse, /opt/eclipse.

Then I entered in plugins folder in that path, no PDT plugin found there, and no CDT plugin I installed for testing either. Then this came to a 99 percent fact that it was a permission issue.

Think I could install PDT again under sudo executing eclipse, but I chose another way, installed another eclipse 4.3.1 in user folder this time, ~/ide/eclipse, where I have full privilege.

And the ending was happy.

Although it was my stupid, and this story maybe not worth telling, but considering I almost gave it up, and there was not any really helpful clue online, so I tell it out here.

Cheers and good night~~

Dec 5, 2013

Install PDT 3.1.1 on Eclipse 3.7 (Indigo)

At first, when I tried to install PDT 3.1.1 on Eclipse 3.7 (Indigo), there was an error that a dependency software missing: DLTK 4.0.

It recalled me about the similar issue when I tried to install ShellED, a bash editor plugin of Eclipse, last month.


While I couldn't update DLTK from Indigo repository:


  http://download.eclipse.org/releases/indigo/

Or

  http://download.eclipse.org/technology/dltk/updates/

But there's a link for the nightly build on DLTK's page http://www.eclipse.org/dltk/install.php

I tried this link in Eclipse install new software dialogue window, this time it returned all DLTK 4.0 packages, wonderful!

After DLTK 4.0 installed, just install PDT 3.1.1 via this source in the installation dialogue:

  http://download.eclipse.org/tools/pdt/updates/release

and finally, as a frosting on the cake, I installed ShellED via this soource:

  http://sourceforge.net/projects/shelled/files/shelled/update/

Happy happy~~

Jan 4, 2013

Bring PHP core auto-complete back in Eclipse 3.7

Imported a project from git server, found that I could not 'Add PHP Support...' to it to get php core function and keyword auto-complete during coding, it was really annoying...

Finally found this solution on Stackoverflow, it works for me.

1. Open file .buildpath in project root path.
2. Add following lines if there is no <buildpath> section:


<buildpath>
 <buildpathentry kind="src" path=""/>
 <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>

3. If there is <buildpath> already, just add this line:

<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>

4. Restart Eclipse.

source link: http://stackoverflow.com/questions/1232647/code-completion-assist-for-built-in-php-functions-in-eclipse-pdt

Sep 19, 2012

Transfer array from PHP to jQuery

I wanted to transfer an array from server side PHP to client side jQuery in metadata, as following:
    ...

    $meta = metadata(array('invalid_chars' => $this->getUnwantedCharCodeArray()));
    return sprintf('<div class="token %s">%s</div>', $meta, $output);
    ...

While in this way what I got at client side is an object, which could not be used in method like $.inArray():

  $('.token').metadata().invalid_chars was an object like object { 0=35, 1=94....}, what I wanted was an array [35, 94...]

Tried .toArray() and $.makeArray(), wouldn't work....

Finally I found a solution: json_encode at the server side and parseJSON at the client side:

Server side:
    ...

    $meta = metadata(array('invalid_chars' => json_encode($this->getUnwantedCharCodeArray())));
    return sprintf('<div class="token %s">%s</div>', $meta, $output);
    ...

Client side:

    if ($.inArray(charCode, $.parseJSON($('.token').metadata().invalid_chars)) > -1 ) { ...
   

Aug 3, 2011

Installing APC (3.1.6) on WAMP (64 bit)

My dev machine has 64bit wampserver installed on windows 7 (MSVC9 (Visual C++ 2008) , Thread Safe, x64). I wanted a caching solution that works well with this setup – As of this writing, APC is the only 64 bit option available.
Get the precompiled TS dll from here (In the comments posted on this page, you will find a link to php_apc.dll without memprotect). Save it in your php “ext” directory.
Add the following line to your php.ini file :
extension=php_apc.dll
Restart apache web server..browse your phpinfo page, and it should have a section for APC – The defaults work fine for a test server setup.
Next, setup the admin page – this will help you view/clear your variable cache(s):
  • Download apc.php from here
  • Save it in your webfolder as apc.php
  • Edit apc.php. Change the admin password (from the default ‘password’ to any string of your liking):
defaults(‘ADMIN_USERNAME’,'apc’);             // Admin Username
defaults(‘ADMIN_PASSWORD’,'pAssW0rd’);      // Admin Password – CHANGE THIS TO ENABLE!!!

Install PHP 5.3.6 on WAMP

I successfully installed PHP 5.3.6 on my WAMP server under Windows 7 64 bit. But this short tutorial will probably work on other versions as well.
Go to the Windows download page at PHP.net and download the desired version. You must select the ZIP VC6 x86 Thread Safe variant.
Unpack the contents to the PHP bin directory in your WAMP installation. I unpacked PHP 5.3.6 in C:\wamp\bin\php\php5.3.6\.
You should now copy the following files from the php5.3.0 directory, to your newly created directory (php5.3.6 in my case): php.ini, phpForApache.ini and wampserver.conf.
Now we just need to make a quick edit in both INI-files. Search for "5.3.0" and replace it with the PHP version you are installing.
Save the files, and you should see the new version in the PHP version menu in WAMP. If not, right-click the WAMP icon and choose "Exit", then start it again.