Run FTP server on Mac OS X

Setup everyhing: sudo subl /etc/ftpd.conf

# match umask from Mac OS X Server ftpd
umask all 022
chroot GUEST /Users/roman/ftp
modify guest off
umask  guest 0707
upload guest on

Start FTP server

sudo launchctl load /System/Library/LaunchDaemons/ftp.plist

And stop again:

sudo launchctl unload /System/Library/LaunchDaemons/ftp.plist

Composer require PEAR package

 "repositories": [
   "type": "pear",
   "url": ""
 "require": {
  "pear-pear/Mail": ">=1.2.0"

How to safely commit vendor dir with php Composer

Composer is great tool, but sometimes you will need avoid all external dependencies. Sometimes you will need have all source codes in your git repository. Should I commit the dependencies in my vendor directory, and still have all benefits of using Composer? Here are my requirements: - Everything need to be automatically.

How to commit vendor dir?

Remove vendor dir from your .gitignore and add follow lines to root of composer.json

"scripts": {
 "post-update-cmd": ["echo [WARNING] Delete all .git dirs", "rm -rf vendor/**/**/.git"],
 "post-install-cmd": ["echo [WARNING] Delete all .git dirs", "rm -rf vendor/**/**/.git"]

That's automatically remove the .git directory of every dependency after the installation or update. You can safely commit everything to your git repo and avoid mistakes with fake git "submodules". Run: composer update and commit everything to your repo. ### How make changes in packages?

When you are using tagged releases (no dev versions) of package then run:

rm -rf vendor/some/package && composer update some/package --prefer-source --no-scripts

For dev versions (dev-master) it's simpler:

rm -rf vendor/some/package && composer update some/package --no-scripts

Now, when you go to vendor/some/package dir it's common git repository - you can make changes, commit and publish new versions of package. But don't forgot run composer update before commit main repo, becouse there is still .git dir in package! ### Disadvantages

Setup email sending from PHP on Mac

First write in terminal: which sendmail wlll return path to sendmail app (in my case /usr/sbin/sendmail). Then open php.ini file and setup:

sendmail_path = /usr/sbin/sendmail -t -i

Create necessary folder and setup postfix permissions:

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

And check if emails will come:

php -r "mail('', 'subject', 'message', 'From: <>' . PHP_EOL);"

Wordpress - How to get user by metadata

Getting user by field name is easy, #Wordpress have function for that get_user_by. Getting user by his metadata is a little bit complicated. You can found on the Internet some complex procedures how to get user by metadata using WP_Query object. Forget about them! You need prepare correct meta query as array or string and call get_users. Thats all!

function get_user_by_meta($meta_key, $meta_value) {
 return reset(
    'meta_key' => $meta_key,
    'meta_value' => $meta_value,
    'number' => 1,
    'count_total' => false