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

Rob Allen:
Using Composer with shared hosting
Dec 28, 2015 @ 15:25:44

Rob Allen has a post to his site talking about using Composer with shared hosting, showing how to use this popular tool even if you're on a shared hosting environment and don't have direct SSH or shell access.

I've seen this sentiment a few times now, so this seems like a good time to point out that you do not need SSH access to your server in order to use Composer. In fact, I don't run Composer on a live server (regardless of whether it's using shared hosting) and it's not on my list of things to do in the near future.

What you do need is a process where you handle your Composer dependencies on your own computer where you have PHP running.

He gives two possible solutions to the problem: either commit your dependencies or create some kind of build script that can execute the Composer install for you on deploy. He gives details on both of these solutions including the process for installing the dependencies with an automated FTP script (run at deploy rather than committed).

tagged: composer shared hosting ftp deploy script commit dependency

Link: https://akrabat.com/using-composer-with-shared-hosting/

PHPMaster.com:
Using cURL for Remote Requests
Aug 08, 2013 @ 14:09:13

PHPMaster.com has posted a tutorial showing you how to use the cURL functionality that can be built into PHP. Note that not all PHP installations will have this extension installed, but most will these days. You can find out by making a phpinfo page.

If you’re a Linux user then you’ve probably used cURL. It’s a powerful tool used from posting mails to downloading the latest My Little Pony subtitles. In this article I’ll explain how to use the cURL extension in PHP. The extension offers us the functionality as the console utility in the comfortable world of PHP. I’ll discuss sending GET and POST requests, handling login cookies, and FTP functionality.

He walks thorough the basic flow of a request and how to set options on the cURL handle to modify its behavior. Several more "real world" examples are also included:

  • Retrieve a Web Page
  • Log in to a Website (via POST data, not HTTP Auth)
  • Working with FTP
  • Sending Multiple Requests

That last one changes things up a bit and uses the curl_multi_init function to create the connection and allow for the multiple request streams to happen.

tagged: curl remote request tutorial login ftp multiple

Link: http://phpmaster.com/using-curl-for-remote-requests

Grzegorz Godlewski:
PHP.Kryptik.AB - Give me your FTP!
Nov 20, 2012 @ 20:14:04

Grzegorz Godlewski has written up a post about a piece of PHP-related malware that, if it gets into your application, can render your site inaccessible (not to mention blocked by Google's "safe browsing") - PHP.Kryptik.AB.

One could think a PHP Developer is free from viruses and malware - and be wrong. Meet PHP.Kryptik.AB - the PHP malware. If you already know this bastard - high five! But if you don’t – be prepared! Basically the story starts from a standard computer trojan which (I suppose) attacks popular FTP clients that store FTP login credentials unencrypted. Then it sends fetched informations to a remote host which (by the cover of night) logs into the FTP servers and infects PHP base web-pages by injecting a piece of JavaScript code, that gets executed when a user enters a site.

He describes the injected code, what kind of files the malware looks for when it executes and how you can fix the problem if you've already been infected. There's also a bit about how you can prevent yourself from being infected (including the suggestion of using something like KeePass or 1Password to manage and create harder to crack passwords).

tagged: malware javascript infect phpkryptikab ftp

Link:

PHPBuilder.com:
My Automated PHP Scripts for Creating FTP Connections to a Remote Server
Jun 19, 2012 @ 15:41:57

PHPBuilder.com has posted a new tutorial about creating automated FTP scripts to pull down information from a remote server (using FTP streams).

In 2007 I began working on a website project for an investment company in my hometown of Cleveland, Ohio USA. The purpose of this website was to automatically download financial data of traded securities from two (2) remote Web servers. [...] Both of these PHP scripts were set up on the Web server's "crontab manager" to automatically run at a set time each business day.

Code is included showing how to connect to the remote service (via curl) with a "ftp" stream-based URL as the location. Also included is an example using a fopen call to the URL and inserting the resulting data into their tracking tables. The other script pulls the data out and adds a new record to a transactions table for the current day.

tagged: ftp tutorial connection transaction mysql cron automation

Link:

PHPBuilder.com:
Transfer Data via Multiple Protocols with Libcurl
Sep 19, 2011 @ 17:03:23

On PHPBuilder.com today there's a new tutorial showing how to use libcurl to communicate with multiple protocols like FTP, HTTP, HTTPS, SMTP and STMPS. The libcurl library that can be compiled in or installed as a shared module in your PHP install to provide enhanced networking abilities.

As I wrote in my PHP multithreading with cURL article, the libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. PHP supports the libcurl library which allows you to connect and communicate to many different types of servers with many different types of protocols.

The tutorial focuses on two different types of connections (well, four really) - FTP/FTPS and HTTP/HTTPS - and how to transfer data across each. Some code is included to create a (procedural) tool to send an uploaded file to a remote site.

tagged: tutorial libcurl ftp ftps http https networking multiple protocol

Link:

PHP and Me Blog:
Use Phing to Update your SVN-Version-Controlled Website Automatically, Through FTP
Jun 20, 2011 @ 16:57:15

On the "PHP and Me" blog there's a new entry from Pinpin Bysma showing how to use the PHP-based deployment tool Phing to update your production website via an FTP connection, automated by a Phing build.

If you're working on a PHP project, like with any other project, probably comes a time when you need to "build a new release," e.g. update the production web site with the latest version of the code. And doing the whole thing manually isn't the most efficient way to get things done, especially if you're lazy, or have to do that every once in a while, over a long period of time. [...] Obviously if updating the site itself could be done without FTP but through a simple svn switch, things would be easier. Still, Phing would allow to make things easier just as nicely. It could for example still be used to create the new tag, trigger the switch, etc

He introduces the process by showing a basic Phing build file that uses the PEAR VersionControl_SVN component to get the latest from the repository and push it to another directory. There was one thing that he wanted to do that the default SVN task couldn't - export the difference between two tags. To make this happen, he had to extend Phing and make a new task - SvnExportDiff. He includes the code for this new task and an updated build file to show it all in use - complete with the FtpDeploy to push the code live.

tagged: phing tutorial svn website deploy ftp custom task

Link:

NetTuts.com:
How to Work with PHP and FTP
May 12, 2011 @ 13:05:21

On NetTuts.com there's a new article stepping you through what you'll need to know about using FTP in PHP, including a basic useful and expandable class.

It’s always important to first outline exactly what functionality your class should include. In our case: connecting to a server, create a folder on the server, upload a file, change directory, retrieving the directory listing and downloading a file.

They first look at what FTP is and then how to set up the class that includes some simple logging, connection handling and how to call the class with a username, password and hostname. The class lets you create a remote directory, upload a file, view a list of remote files and downloading a selected file. Full source for the class is available as a download.

tagged: ftp tutorial class

Link:

PHPBuilder.com:
Implementing Internet Protocols with PHP
Jan 13, 2011 @ 14:20:24

On PHPBuilder.com today there's a new tutorial from Leidago Noabeb that looks at implementing internet protocols - in this case FTP.

PHP has many functions that help us to implement Internet and/or networking protocols. In this article we will look at how to implement some of those protocols using PHP.

His examples uses PHP's FTP methods to create a simple frontend to a remote FTP server. Included is the code to get the basics of it working - listing remote files and displaying them out in a styled list.

tagged: tutorial internet protocol ftp

Link:

Justin's Blog:
An ftp server written in PHP
May 19, 2009 @ 15:40:30

Justin has written up a quick look at a FTP server that's been written entirely in PHP - nanoFTP.

nanoFTPd is an ftp daemon written in php. as of version 4.2.0, php supports the command-line interface (stable since 4.3.0), which nanoFTPd relies on. nanoFTPd is modular, so it’s easy to add custom modules and other stuff, like different database interfaces (currently supports mysql and postgresql).

The server allows for a lot of the usual FTP functionality - uploads, downloads, user authentication, logging, etc. It works with PHP 4.2 and above and is pretty simple to install.

tagged: server nanoftp ftp

Link:

Community News:
phpanywhere (Online PHP IDE)
Apr 29, 2009 @ 16:12:18

The phpanywhere site boasts itself as "the easiest way to bring work with you anywhere you go - without bringing anything". The free (still in beta) service offers online PHP editing through a web browser interface.

PHPanywhere is a web based free Integrated Development Environment or IDE for the PHP language, in other words it is an application that gives developers all the code editing capabilities they need to develop PHP applications online. It includes a real-time syntax code editor with support for all web formats and a powerful FTP editor.

You can add in FTP servers and pull files directly from them to edit and upload back over. You can also use the project sharing to allow others to see the current state of your code (real-time collaboration is "coming soon"). You can see screenshots of the editor interface, setting up FTP sites and modifying permissions for the files.

tagged: phpanywhere online ide edit ftp share

Link:


Trending Topics: