Difference between revisions of "PHP"

From ArchWiki
Jump to: navigation, search
(use new templates, see Help:Style)
m (it's not really necessary to note the latest version at the top of the page (it was outdated anyways))
Line 1: Line 1:
[[Category:Daemons and system services (English)]]
[[Category:Daemons and system services (English)]]
== Latest version ==
PHP 5.3 is released 30 June 2009. ([http://www.php.net/archive/2009.php#id2009-06-30-1 ''Source''])
== Server setup ==
== Server setup ==
How to setup PHP, Apache and MySQL see on [[LAMP]] page.
How to setup PHP, Apache and MySQL see on [[LAMP]] page.
=== PHP Fatal error:  Class 'ZipArchive' not found ===
=== PHP Fatal error:  Class 'ZipArchive' not found ===
Ensure the zip extension is enabled.
Ensure the zip extension is enabled.

Revision as of 01:46, 5 January 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Server setup

How to setup PHP, Apache and MySQL see on LAMP page.

PHP Fatal error: Class 'ZipArchive' not found

Ensure the zip extension is enabled.

$ grep zip /etc/php/php.ini

Zend Core + Apache

Zend Core is the official PHP distribution provided by zend.com. It includes an installer/updater, zend optimizer, oracle support, and necessary libraries. However, it lacks support for postgresql, firebird, and odbc.

  • Install mod_fcgid (pacman -S mod_fcgid), a FastCGI module for apache (the official one sucks).
  • Install Zend Core (official php distribution)
    • Uninstall arch linux's php package.
    • Download and install zend core from http://www.zend.com/products/zend_core ; don't install the bundle apache or tell it to setup your web server. It always installs to /usr/local/Zend/Core due to hard-coded path.
    • Create a script /usr/local/bin/zendcore and create symlinks to php, php-cgi, pear, phpize under /usr/local/bin
      export LD_LIBRARY_PATH="/usr/local/Zend/Core/lib"
      exec /usr/local/Zend/Core/bin/`basename $0` "$@"
  • Setup Apache:
    • In /etc/httpd/conf/httpd.conf, add
      LoadModule fcgid_module lib/apache/mod_fcgid.so
      <Directory /srv/http>
      AddHandler fcgid-script .php
      FCGIWrapper /usr/local/bin/php-cgi .php
      Options ExecCGI
      Allow from all
      SocketPath /tmp/fcgidsock
      SharememPath /tmp/fcgidshm
    • Remember to change the Directory path
  • Disable Zend Optimizer (so you can use cache):
    • Edit /etc/php.ini, uncomment the following line near the end of file:
  • Install APC (Alternative PHP Cache):
    • Run pear install pecl.php.net/apc as superuser.
    • Edit /etc/php.ini, add the line after "; Zend Core extensions..." (line 1205):
  • Update Zend Core and/or install other components
    • Just run /usr/local/Zend/Core/setup

Development tools


See Eclipse PDT.

PDT is not very complete at the current stage (v0.7); for instance, it cannot pop-up class list automatically when you type, though you can add custom auto-activation trigger keys.

You would need other plugins for javascript support and DB query.


Good integration for PHP+HTML+JavaScript. Lacks code formatting and unicode support in doc comments.

Komodo IDE | Komodo Edit (free)

Add custom encodings:

  • Edit KOMODO_INSTALL_DIR/lib/mozilla/components/koEncodingServices.py, line 84, add:
 ('cp950', 'Chinese(CP-950/Big5)', 'CP950', '', 1,'cp950'),
 ('cp936', 'Chinese(CP-936/GB2312)', 'CP936', '', 1,'cp936'),
 ('GB2312', 'Chinese(GB-2312)', 'GB2312', '', 1,'GB2312'),

The format is (encoding name in python, description, short description, BOM, is ASCII-superset?, font encoding)

Zend Studio Neon

Official PHP IDE, based on eclipse. Replace old Zend Studio.

Zend Studio NeonTemplate:Linkrot

The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins.

Zend Code Analyzer

PHP code analyzer from Zend Studio. The program is indispensable for any serious PHP coding.

To install it:

  • Download and install Zend Studio Neon
  • In the installation dir, run
 find . -name "ZendCodeAnalyzer"

to get the path.

  • Copy ZendCodeAnalyzer to /usr/local/bin/zca
  • Now you can remove zend studio; you won't need a key or anything.

Integrate with Eclipse, Error Link plugin:

  • Symlink zca to build.zca (so Error Link can recognize it)
  • Install Sunshade plugin suite;
  • Preference -> Sunshade -> Error Link -> Add: ^(.*\.php)\(line (\d+)\): ()(.*)
  • Run -> External Tools -> Open External Tools Dialog -> Select "Program" -> Clicn on "New":
    Name: Zend Code Analyzer
    Location: /usr/local/bin/build.zca
    Working Directory: ${container_loc}
    Arguments: --recursive ${resource_name}

Integrate Komodo, Toolbox -> Add -> New Command:

  • Command: zca --recursive %F
  • Run in: Command Output Tab
  • Parse output with: ^(?P<file>.+?)\(line (?P<line>\d+)\): (?P<content>.*)$
  • Select Show parsed output as a list

Integrate with Vim, in ~/.vimrc add:

 autocmd FileType php setlocal makeprg=zca\ %<.php
 autocmd FileType php setlocal errorformat=%f(line\ %l):\ %m