- requires version 2016.2 (currently EAP)
- Xdebug only enabled when needed, means Composer, unit tests etc. will be much faster
See also my (regularly updated) PhpStorm Xdebug troubleshooting post.
Web developer.
Blog default.
See also my (regularly updated) PhpStorm Xdebug troubleshooting post.
This is a common problem – the error is in Illuminate/Container/Container.php (line 736 or 741).
Common reason: spaces in environment variable values in .env file
Two other fixes that have worked for me:
$app->environment('production')
to:
'production' === env('APP_ENV')
in a ternary operator in config/app.php was the solution.
Mattias Geniar has written this up in some detail, but to summarise:
Nginx 1.10 (the new major, stable version) has replaced SPDY with HTTP/2. But as of this week, Chrome now only supports HTTP/2 using ALPN. ALPN requires OpenSSL 1.0.2. But stable Debian (and CentOS, and other flavours of Linux) only have 1.0.1 and, right now (it seems to me) there’s not a lot of hope Debian will back-port the new version: many other services also use OpenSSL, they’d all need to be checked/updated…
If you’re using DotDeb on Jessie (aka Debian 8), the nginx packages (nginx nginx-common nginx-full etc.) will be held back when running apt-get upgrade.
What should I do? Updated – SOLUTION AVAILABLE! (2 March 2017) A newer OpenSSL has been backported. You need to add some extra repositories and use a special command to install it, but that’s it. Full Instructions
Updated Fri 7 Dec 2018.
Running Xdebug remotely is very useful – you can add breakpoints, inspect and modify the state of all variables/objects and type PHP code into a live console. No need to manual add var_dump() statements etc.
It should save you a lot of time.
Unfortunately, while the setup should be straightforward, it’s easy to lose the programming time you save spending ages tweaking your Xdebug and PhpStorm configuration to get it to work in the first place. (In fact, I don’t think it’s worked correctly first time for me once.)
Also, you’ve probably got multiple projects, maybe running on different VMs, or using Docker (scroll down for special instructions for Docker on the Mac).
There’s an element of “it just works” for Xdebug in the server/PhpStorm configuration when using Acquia Dev Desktop or Drupal VM.
To enable/disable Xdebug:
edit /Applications/DevDesktop/php7_1/bin/php.ini
Uncomment the zend xdebug extension and turn on remote_enable
zend_extension=xdebug.so xdebug.remote_enable = 1
Restart Apache – via one of:
cmd-2
(stop) then cmd-1
(start)/Applications/DevDesktop/apache/bin/apachectl -k restart
To turn on xdebug, make sure you’ve got:
php_xdebug_default_enable: 1
and:
installed_extras: [...] - xdebug
Then run vagrant provision
to build/rebuild (this won’t affect your site). Leave PhpStorm set to port 9000.
On other installations, here’s my growing checklist when I try to use Xdebug and nothing happens:
(The following is based on Xdebug 2.4.0RC4 and PhpStorm 2016.2.1)
Step 1: you should identify whether it’s a complete lack of communication between Xdebug and the IDE, or if PhpStorm is receiving the data the data but is setup wrong.
Close and restart PhpStorm. Make sure PhpStorm is listening for PHP Debug Connections (bottom of Run menu, or green telephone icon top right), then reload your app in the browser.
What you’re looking for is either:
a) an ‘Incoming connection’ dialog the very first time you open a webpage of your app.
or
b) ‘Debug session was finished without being paused” in the Event Log.
Either of these confirms Xdebug is talking to PhpStorm and you can need not worry about your php.ini entries, the possibility you’re using the wrong port or that you forgot to trigger the bookmarklet – goto section B.
If nothing happened at all, go to section A.
wt$ sudo lsof -i :9001 Password: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME phpstorm 80592 wt 330u IPv4 0xaad56de5076720c3 0t0 TCP *:etlservicemgr (LISTEN)
If PhpStorm is not listening this will be blank.
Note: you might want to set the PHP_IDE_CONFIG environment variable on your server. This tells PhpStorm which path mapping configuration it should use so it doesn’t prompt you. It needs to be written like this:
serverName=my-server.dev
where my-server.dev
must match the name configured in Languages & Frameworks > PHP > Servers – as shown below:
Go to: Run > Web Server Debug Validation (instructions here)
Your Docker containers will have an IP address beginning 172.xxx.xxx.xxx (each container gets it’s own – check what it is) You might assume that’d be enough to avoid conflicts with your real IP address or 127.0.0.1 when specifying xdebug.remote_host.
Note: on macOS, you need to create a symlink to your IP otherwise PhpStorm won’t be able to hear Xdebug.
sudo ifconfig lo0 alias 10.254.254.254
Restart everything and things should start working.
Related info:
In version 2.0 of MailChimp’s API, there was a helper/ping endpoint, which is useful for automated monitoring (e.g. Nagios checks.)
This no longer exists in v3.0, which is quite a bit different.
Just to share the recommendation their API support team gave me, use the API Root resource instead, and assuming you don’t need all the data it returns, just append ?fields=account_name
and it will only send that specific field back.
I’d recommend logging the HTTP response code too and checking it’s 200, e.g. in PHP:
$http_status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
a.k.a. the Cookie Law. You might have views on it. The consultation is open until July.
Scenario: You’ve accidentally deleted a bunch of AVI files on an SDHC memory card. You’ve also emptied the Trash in OS X, which would ordinarily mean they’re permanently lost.
mount
to identify the disk format (in this case a FAT-32 partition from Keedox Trail camera)diskutil unmount /dev/<whatever>
(or you can open Disk Utility and use the GUI)sudo diskutil
(if you don’t run as root, chances are you won’t see the full list of drives)C
to copy, choose a destination folder, etc.AVI files not loading
I now had AVI files which were correctly named (apart from the initial _
) and timestamped, but looked about twice as big as they should be and wouldn’t play due to unrecognisable header info. They wouldn’t open in OS X Quick Look or VLC, DivFix++ kept giving me “Seek error” and trying to recover them by regenerating with ffmpeg:
ffmpeg -i input.avi -c copy output.avi
…didn’t work either.
The equivalent did work in mencoder though, and it’s very fast:
mencoder -idx input.avi -ovc copy -oac copy -o output.avi
I had a whole bunch of files (_ICT0001.AVI, _ICT0002.AVI etc.) for which you can use ‘find’ and a bash script:
find * -name '_ICT*.AVI' -type f -exec ~/avifix.sh {} \;
avifix.sh: (test it on a single file first)
#!/bin/bash mencoder -idx $1 -ovc copy -oac copy -o repaired-$1
Updated Wed 14 Sep 2016 (new installation guide URL, clarify name change.)
Let’s Encrypt have updated their getting started page, but the following may help anyone trying to understand the latest changes.
If you’re installing from scratch, use Certbot (see below) and start here. You’ll get custom instructions for your operating system and web server – the client can now be installed via a package on newer systems.
The client (now at version 0.6.0) from letsencrypt-auto to Certbot – to be precise, the project/ecosystem is still called Let’s Encrypt, while Certbot is the EFF’s certificate deployment client.
You’ll find that certbot-auto (a shell script) is an exact copy of the letsencrypt-auto, so all previous commands will still work.
The git repository has also been renamed – the old one is redirected.
Old: https://github.com/letsencrypt/letsencrypt
New: https://github.com/certbot/certbot
You can update the location of your ‘origin’ remote in .git/config
You can now renew all your certificates at once.
# to test ~/letsencrypt/certbot-auto renew --dry-run # to actually do it ~/letsencrypt/certbot-auto renew
There’s some clever stuff going on here:
--dry-run
use staging server, so doesn’t count towards API limits.Example of a cron.weekly script you could use:
#!/bin/bash /path/to/letsencrypt/certbot-auto renew service nginx reload
Updated Tue 10 May 2016
Gravity Forms doesn’t return or record success or failure of emails, so you may find yourself having to resend them if there was a problem.
It is already possible to trigger notifications for form entries again via the WordPress admin interface, but it requires a lot of clicking should there be very many of them. Also, although the Directory Columns option allows you to customise the fields displayed, the entry submission date/timestamp is not available here.
Here’s a very quick plugin which uses WP-CLI and the GFAPI to show you a whole batch of entries for a form and filter by start/end date (or date and time).
You can also view a summary of the main notification settings (from/to/reply-to addresses, subject line) for all (or selected) forms.
Full syntax/help is available with:
wp help gftuil renotify wp help gfutil notifications
This is a fairly crucial bit of object-oriented PHP, but I only found out about it today after x years, so it’s bound to trip someone else up.
Essentially, if you want to copy some values from an object, doing this is a very bad idea:
$a = new A;
$b = $a;
…because it’s not like copying a variable (passing it by value) where $a and $b are independent, $b is just a pointer to $a. So this:
unset($b->foo);
…will remove foo from $a as well.
Wiser programmers than me may well be saying, “Why do you need to copy an object anyway?”, and indeed I can’t remember doing so before.
I needed it’s properties, so I could write a record of an API call to a logfile (but minus sensitive info like the API keys). These were indeed removed from the log, unfortunately all the REST calls stopped working and it took a while to realise why. get_object_vars (which chucks the properties in an array and leaves the original object intact) was what I should have used.
Note objects are passed as pointers, not as references, as explained in great detail here (read the comments.)