Saturday, March 31, 2018

Xdebug install and usage with PhpStorm

get info about which version of debug you need to download - https://xdebug.org/wizard.php
install - https://www.youtube.com/watch?v=OlcsQ8TCU3A
usage https://www.youtube.com/watch?v=RiViVMIrbh0
xdebug - extensions for firefox and chrome

settings in php.ini with PhpStorm
[xdebug]
zend_extension = /usr/lib/php/20160303/xdebug.so
xdebug.default_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1

Friday, March 16, 2018

cURL in Command Line

Following snippets can be used for testing RESTful API:

# simulate form submission 
curl -X POST -F 'name=test' -F 'password=123' -F 'csrf_token=abc' http://127.0.0.1:8000/login
# or
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'name=test&password=123&csrf_token=abc' http://127.0.0.1:8000/login

# post JSON
curl -X POST -H "Content-Type: application/json" -d '{"name":"title1", "role":"role1"}' http://127.0.0.1:8000/user

# plain GET
curl -X GET http://127.0.0.1:8000/user/1
curl -X GET http://127.0.0.1:8000/user

# PUT
curl -X PUT -H "Content-Type: application/json" -d '{"name":"other title1",  "role":"other role1"}' http://127.0.0.1:8000/user/1

# DELETE
curl -X DELETE http://127.0.0.1:8000/user/1

Set Apache Alias

If you want to put WordPress to sub folder you need to create file wp03.conf with following content:

Alias /wp03 "/var/www/wp03"
<Directory "/var/www/wp03">
 AllowOverride All
 Options FollowSymlinks
 Order deny,allow
 Deny from all
 Allow from all
 Require all granted
</Directory>

Now you can access your blog on http://localhost/wp03