Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Adam Culp:
Using an SSH tunnel to step debug through a firewall
Apr 19, 2016 @ 15:54:28

Adam Culp has followed up some of his previous posts about the setup and configuration of remote debugging in PHP applications (more specifically in Zend Studio) with this new post. In it he shows how to use a SSH tunnel to allow debugging to happen through a firewall for those cases when direct access isn't possible.

In a previous post I covered how to set up step debugging in Zend Studio. But if that doesn’t work there may be a firewall in between the server and the debugging client, or IDE, preventing the connection. Here is a possible way to get around that.

He assumes that you already have the SSH server and connection available to you (he doesn't cover the install of that part). He then steps you through the setup of Zend Studio to add a new server, configure the SSH tunneling and remote/local ports to use. In his case he was using Zend Server so switching on debugging was as easy as turning in debugging via the toolbar. It's also worth noting that another popular PHP IDE can handle SSH-based debugging as well - PHPStorm - as seen here.

tagged: remote debugging ssh zendstudio setup configure tutorial phpstorm

Link: http://www.geekyboy.com/archives/1242

Rob Allen:
Using Phing to SSH into a Vagrant box
Nov 25, 2014 @ 16:22:55

In a quick new post to his site Rob Allen shows you how to have Phing SSH into a Vagrant box as a part of the VM creation process. In his case, he uses it to run database migrations.

Now that I've started using migrations, I've discovered a minor irritant. I run this project on a Vagrant VM and have discovered that I keep forgetting to ssh into the vagrant box before running the migrations script. The obvious solution is to automate this and I decided to use Phing to do so.

He walks through the installation of the libssh2 software (if you don't already have it) and the ssh2 PHP extensionSshTask to make the connection as the "vagrant" user and execute the given PHP command.

tagged: vagrant ssh phing migrations automate tutorial vm virtualmachine

Link: http://akrabat.com/php/using-phing-to-ssh-into-a-vagrant-box/

SitePoint PHP Blog:
Deploy Your Website Using Laravel and Git
Sep 08, 2014 @ 14:28:50

The SitePoint PHP blog has a new tutorial by James Dow showing you how to use git and Laravel for application deployment. This isn't just about deploying a Laravel application, though. It includes a method for automating processes once the deployment is complete.

You can’t be a successful web developer without using some sort of deployment workflow for your websites. It doesn’t matter how good or bad your workflow might be. If you can’t get your website up to production then your client will never pay you for your hard work. [...] I wanted something that was as easy as pushing a repository with Git. More important, I wanted to be in full control when pushing content live. I was able to find a similar workflow that used Git to handle the file transferring. On top of that I found out I could also use the PHP framework Laravel to automate the more repetitive tasks.

He starts with the server side of things, showing you how to get the git repository created and structured. He then configures Laravel with a "remote" connection for the production server so it can reach out and execute the tasks. Finally he shows how to make the route (/deploy) that's executed when the route is called. In his example route he sets up a SSH request to the production server that changes to the web server root and makes a "git pull" request to get the latest code. It's an interesting use for something like Laravel, but I wonder if it's a good fit for the deployment need. This kind of thing could pretty easily be replaced with a small shell script.

tagged: deployment laravel tutorial git ssh

Link: http://www.sitepoint.com/deploy-website-using-laravel-git/

PHPMaster.com:
Using SSH and SFTP with PHP
Jan 10, 2013 @ 17:31:52

On PHPMaster.com today there's a quick tutorial showing you how to use SSH and SFTP from inside your PHP applications (requiring the ssh2 package).

In today’s world with so many third-party integrations and content-sharing, it’s important to understand and make use of protocols like SCP and SFTP. PHP’s SSH2 extension, a wrapper for libssh2 which implements the SSH2 protocol, provides several functions you can use to securely transfer files.

Sample code is included showing how to make a SSH request to a remote server, define the key files to use and execute a remote command (like scp). They also mention the use of wrapper functions like mkdir that also work with SSH/SFTP connections. The post finishes up with an example class or two you can use to wrap your connection handling and make it a bit more OOP-friendly.

tagged: ssh sftp extension pecl tutorial oop

Link:

Lorna Mitchell's Blog:
Using an Existing Vagrant Setup for PHP Development
May 09, 2012 @ 15:50:24

In this new post to her blog Lorna Mitchell dives into the world of vagrant/puppet/chef and looks at using the tools to automatically create VMs that you can use for PHP development (or testing).

I've been hearing great things about puppet, chef, vagrant, and friends for a while now, but since I work on my own I tend to either develop straight onto my ubuntu machine or grab an appropriate existing VM and use that. So I read about this brave new world of virtualisation but (as with most tools) they can be hard to introduce on your own, and I didn't. [...] Then I went to WhiskyWeb, which had a hackathon [...] with the shiny new technology all packaged for me, I decided it was time to take a look!

She shows you how to get the VM started up using vagrant, pausing the instance and removing it all together (destroy). She also includes the command to directly access the VM via ssh and links to the joind.in project with its sample puppet configuration and Vagrant file.

tagged: vagrant introduction setup development ssh suspend puppet chef

Link:

Mark Hamlin's Blog:
Debugging xdebug (tcp, dns, ubuntu, osx, vmware) ((all at once))
Aug 31, 2011 @ 18:04:43

In a recent post to his blog Mark Hamlin talks about some of his difficulties in getting XDebug and Netbeans working together from an OSX machine hitting a Ubuntu server.

For the past 18 months working with PHP, i've primarily used alternatives, not out of preference, but because netbeans xdebug integration consistently failed me. It would (might) work with a remote apache, but would not play with scripts executed remotely from the command line. I could be fairly sure my xdebug config was sound as I no problems with MacGDB and PHPStorm whatsoever.

With a little more investigation, he discovered that it was the OSX firewall causing issues. He found that, with a new incoming connection came a confirmation box to approve the connection. This, of course, wasn't passed along to Netbeans so he never saw it. In the end, he set up a reverse SSH tunnel to bypass the firewall completely (command included).

tagged: debug netbeans firewall xdebug ssh tunnel ubuntu osx

Link:

Derick Rethans' Blog:
Remote Debugging PHP with a Firewall in the Way
Aug 26, 2011 @ 16:24:17

Sometime debugging PHP applications isn't as easy as just pointing your IDE directly at the server and starting to work. Derick Rethans has a new post talking about one such situation, remote debugging with a firewall in between you and the remote machine with XDebug.

The PHP debugging extension Xdebug has "remote" debugging capabilities for single-step debugging PHP applications. This works by setting your favourite IDE into listening mode and instructing Xdebug (with one of the handy browser extensions for example) to initiate debugging. [...] There could however be a firewall in the way that prevents Xdebug connecting directly to your IDE's IP address. That can be because the network you are on employs NAT. [...] In this case, there is no way Xdebug can connect to your IDE's IP address and port. Or is there?

His alternative requires SSH access to the remote machine - building a tunnel from your local machine to the remote server XDebug can use to get around the firewall. He explains the shell command to set up the tunnel and, a more graphical way, through the Putty ssh/telnet client. A quick call to "netstat" can tell you if things are working correctly or not. All that's left then is to point your XDebug to the port on the localhost and you should be good to go on debugging.

tagged: debugging firewall tutorial ssh tunnel xdebug ide

Link:

NetTuts.com:
Managing Cron Jobs with PHP
Apr 08, 2011 @ 17:39:30

New on NetTuts.com there's a tutorial about using cron with PHP and how to manage the jobs your server currently runs.

The cronTab, or “Cron Table”, is a Linux system process / daemon which facilitates the scheduling of repetitive tasks thereby easing up our day to day routine. In this tutorial, we’ll create a dynamic PHP class that, using a secure connection, provides us with a means to manipulate the cronTab!

They explain the cron format (time and script to run) and how to set up a crontab management class that uses the ssh extension for PHP to communicate with the remote server. Their class includes methods for setting up jobs, writing them out to the cron file, removing existing jobs and dropping the entire cron file at once.

tagged: cronjob manage ssh tutorial

Link:

Mark Karpeles' Blog:
PHP can do anything, what about some ssh?
Jun 28, 2010 @ 18:38:18

In an effort to just about everything he can with PHP Mark Karpeles has posted an article about how he created a SSH server in PHP with most (not quite all) of the functionality of some of its counterparts.

You probably know SSH at least by its name. It’s a of secure telnet replacement which also allows many other things such as port forwarding, remote file management (with sftp) and more. With PHP I could write a fully working SSH server in only 3 days. [...] My goal when writing this was to provide a replacement for the FTP protocol for the customers of my hosting service.

He lists the extensions used to create the extension - OpenSSL, mcrypt, hash and (the most important) GMP as well as a link to the source if you'd like to try it out yourself.

tagged: openssl mcrypt has gmp ssh server

Link:

Till's Blog:
PEAR & Plesk
Dec 10, 2008 @ 15:34:15

In this new post to till's blog, he looks at a method for setting up PEAR on a Plesk system.

Now running any config interface is a blog entry by itself and when I say Plesk, I should also mention confixx and cpanel. And while I have a strong dislike for all them, let me focus on Plesk for now. This is not a copy'n'paste howto, so make sure you double-check all steps involved. With little knowledge, you should be able to to apply all instructions to any other control panel, all you need is SSH access to the server.

The process includes two different sections - why your PEAR installation may not be working and how to install the PEAR packages (on any system supporting a package manager). Command line calls and configuration options are also included.

tagged: pear plesk install troubleshoot package controlpanel ssh

Link:


Trending Topics: