среда, 15 мая 2013 г.

Configure PhpStorm for debugging

Params:
IDE: PhpStorm6
OS: Ubuntu 12.10

Problem: 
Configure IDE for debugging.

Solution:
1) At first install and configure XDebug.


 My additional xdebug.ini options:
  • xdebug.remote_enable=On
  • xdebug.remote_host=localhost
  • xdebug.remote_port=9000
  • xdebug.max_nesting_level=250

Do not forget restart your web server with new configuration.
Also you can check if XDebug is used in phpinfo output.

2) Install and configure "Xdebug Helper" plugin in browser(chrome for example)
I using https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
Configuration options for it:
IDE key Other:PHPSTORM1
Or you can try another key from PhpStorm documentation page:
http://www.jetbrains.com/phpstorm/marklets/

3) Configure PhpStorm:
Add your app server: File -> Settings -> PHP -> Servers (Debugger: Xdebug)
Configure debug options: File->Settings->PHP->Debug
  Xdebug | debug port - 9000
  Xdebug | Can accept external connections - checked


Debuging
Run->Break at first line in PHP scripts - check it
Run->Start Listen PHP Debug Connections - enable listener
Go to debugging page in browser.
Click on gray bug icon and enable Debug.
After these actions all should be ready, so reload page(or send a form, or click on link, ...) and debug will start.

Thanks to authors from these resources:
http://icephoenix.us/php/how-to-setup-local-php-debugging-with-phpstorm-and-xdebug/
http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/
http://blog.jetbrains.com/webide/2011/03/configure-php-debugging-in-phpstorm-2-0/

среда, 20 февраля 2013 г.

Apache2 Negotiation: discovered file(s) matching request

Params:

 - Linux A230512 3.5.0-24-generic #37-Ubuntu SMP Thu Feb 7 01:50:30 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
 - Apache/2.2.22

Problem:
I trying to get page from local server by URL: http://<sitename>/index/index/site_id/6. There one input point "index.php", htaccess configured properly. But "Page not found" returned.

Solution:
Apache log show this message "Negotiation: discovered file(s) matching request...". It mean you need to disable "MultiViews" in domain configuration.

1) Edit domain configuration file
> nano -w /etc/apache2/sites-available/<site-configuration-file>
2) Find this row "Options Indexes FollowSymLinks MultiViews" and remove phrase "MultiViews".
As a result you should have this "Options Indexes FollowSymLinks". Save file.

3) Restart apache
/etc/init.d/apache2 restart

Note:
OS Ubuntu 12.10, In your system routes and commands may be different.

среда, 16 января 2013 г.

Configure ZendDebugger for PHP5.4

Params:
OS: Ubuntu12.10 - Linux A230512 3.5.0-21-generic #32-Ubuntu SMP Tue Dec 11 18:51:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Web server: Apache2
PHP: PHP 5.4.6-1ubuntu1.1  Zend Engine v2.4.0

Problem:
Need to debug php scripts with ZendStudio10(beta!). But officially Zend doesn't produce Debugger for PHP v5.4, latest version for v5.3

Solution:
Main idea: download ZendServer package for PHP5.4 get ZendDebugger from this pacakge and install it manually. Follow those steps and you will be fine!

1) Get deb package of ZendServer(depending your system 64 bit or 32) for PHP5.4
> wget http://repos-source.zend.com/zend-server/preview-php5.4/deb/pool/php-5.4-debugger-zend-server_5.3.33+b7_amd64.deb
2) Unpack it:
dpkg -x php-5.4-debugger-zend-server_5.3.33+b7_amd64.deb php54debugger
3) Copy ZendDebugger.so to the right place:
cp ./usr/local/zend/lib/debugger/php-5.4.x/ZendDebugger.so /usr/lib/php5/20100525/ZendDebugger.so
4) Copy zend debugger.ini to the right place:
cp ./usr/local/zend/etc/conf.d/debugger.ini /etc/php5/mods-available
5) Now you need to replace one string that ini file. Find this string
zend_extension_manager.dir.debugger=/usr/local/zend/lib/debugger
and replace it to this
zend_extension=/usr/lib/php5/20100525/ZendDebugger.so
6) Enable this ini file:
ln -s /etc/php5/mods-available/debugger.ini /etc/php5/fpm/conf.d/30-debugger.ini
7) Restart web server:
/etc/init.d/apache2 restart

This works for me from the box, no additional actions.

PS. All scripts and commands depends of your OS, in this version its Ubuntu.
Giant thanks to the author of this post original version

среда, 26 сентября 2012 г.

bash, colored output

Params:
Linux A230512 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Qt: 4.8.1

KDE Development Platform: 4.8.5 (4.8.5)
Yakuake: 2.9.8


Problem:
Need colored bash output.

Solution:
Edit your ~/.bashrc configuration file.
Find this parameter force_color_prompt and set it to yes.
force_color_prompt=yes

четверг, 13 сентября 2012 г.

Enable $HTTP_SERVER_VARS and $HTTP_GET_VARS in PHP5

Params:
PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch

Problem:
In php4 project not defined variables $HTTP_SERVER_VARS and $HTTP_GET_VARS

Solution:
Enable php directives register_globals and register_long_arrays
You can do it in your php.ini configuration file, but the best way do it in .htaccess file in your specific project.

понедельник, 10 сентября 2012 г.

Git remove submodule

Params:
git version 1.7.9.5

Problem:
Bundles DoctrineFixturesBundle and DoctrineMigrationsBundle has changed repository URLs and namespaces. So I can't update submodules.

Solution:
1) Remove appropriate sections in .git/config file:
pattern: git config -f .git/config --remove-section submodule.$submodulepath
> git config -f .git/config --remove-section submodule.vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle
> git config -f .git/config --remove-section submodule.vendor/bundles/Symfony/Bundle/DoctrineMigrationsBundle
It also remove appropriate sections in .gitmodules file, if not, use this command:
pattern: git config -f .gitmodules --remove-section submodule.$submodulepath
2) pattern: git rm --cached $submodulepath
> git rm --cached vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle
> git rm --cached vendor/bundles/Symfony/Bundle/DoctrineMigrationsBundle

3) Commit this changes:
> git commit -m "Remove submodules DoctrineFixturesBundle and DoctrineMigrationsBundle"

Midnight Commander color scheme and code highlight

Params:
Linux A230512 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
GNU Midnight Commander 4.8.1

Problem:
Need another color scheme and code highlightes in Midnight Commander.

Solution:
Configuration file for mc-4.8.1 located here:
~/.config/mc/ini

1) Enable code highlightes in mc editor.
Change highlight parameter in mc config file to 1:
editor_syntax_highlighting=1
May be you need to copy misc/filehighlight.ini file from mc source to /etc/mc directory.

2) Apply custom color scheme. 
Set appropriate parameter:
[Color]
base_color=lightgray,default:normal=lightgray,default:selected=black,green:marked=yellow,default:markselect=white,green:errors=white,red:menu=lightgray,default:reverse=black,lightgray:dnormal=white,default:dfocus=black,green:dhotnormal=brightgreen,default:dhotfocus=brightgreen,green:viewunderline=brightred,default:menuhot=yellow,default:menusel=white,black:menuhotsel=yellow,black:helpnormal=black,lightgray:helpitalic=red,lightgray:helpbold=blue,lightgray:helplink=black,cyan:helpslink=yellow,default:gauge=white,black:input=black,green:directory=white,default:executable=brightgreen,default:link=brightcyan,default:stalelink=brightred,default:device=brightmagenta,default:core=red,default:special=black,default:editnormal=lightgray,default:editbold=yellow,default:editmarked=black,cyan:errdhotnormal=yellow,red:errdhotfocus=yellow,lightgray

!!! IMPORTANT !!!  - use nano or vi or ... to edit mc ini file, but not internal mc-editor,
otherwise your changes will be lost
!

PS: Thanks to this post author. 

http://plug-and-pray.blogspot.com/2009/09/editing-midnight-commanders-color.html
Her color scheme is beauty.