How can I add ftp extension to Heroku php app? - php

I am developing a Facebook app using heroku. My app needs the ability to upload files (pictures) to a folder on a remote server, and I assume ftp is the best option. Unfortunately the ftp extension is not enabled out of the box. I spoke with support and they suggested the following:
"We unfortunately don't support FTP, or any PHP extension at this moment.
But the good news is that we just open sourced our PHP build pack, so you could try to vendor it yourself:
https://github.com/heroku/heroku-buildpack-php"
So I am assuming I can follow the readme instructions in the link above, and simply include the --enable-ftp option?
This is a bit beyond my current knowledge. I really appreciate the help, and look forward to learning something new.

I had to do something similar. Here's what I did:
1.You need to use a custom buildpack which installs the pear packages Net_FTP. I suggest that you fork the one I've been using (https://github.com/antonyevans/heroku-buildpack-php/)
Then you need to change bin/compile. Key changes are the removal of the lines (around 163):
php/bin/pear install mail
php/bin/pear install Net_SMTP
And the addition of Net_FTP extension:
php/bin/pear install Net_FTP
2.Then you need to tell your application to load the package:
require_once 'Net_FTP.php';

Your biggest problem is that the Heroku file system is emphemeral. I would suggest going back and looking at your architecture again.

Related

How to include PHP library in Python package (on not do it)

I've created tool, that runs as a server, and allow clients to connect to it through TCP, and run some commands. It's written on python 3
Now I'm going to build package and upload it to Pypi, and have conceptual problem.
This tool have python client library inside, so, after installation of the package, it'll be possible to just import library into python script, and use for connection to the daemon without dealing with raw TCP/IP.
Also, I have PHP library, for connection to me server, and the problem is - I don't know how to include it into my python package the right way.
Variants, that I found and can't choose the right one:
Just include library.php file into package, and after running "pip install my_package", I would write "require('/usr/lib/python3/dist-packages/my_package/library.php')" into my php file. This way allows to distribute library with the server, and update it synchronously, but add long ugly paths to php require instruction.
As library.php in placed on github repository, I could just publish it's url in the docs, and it'll be possible to just clone repository. It makes possible to clone repo, and update library by git pull.
Create separate package with my library.php, upload it into packagist, and use composer to download it when it's needed. Good for all composer users, and allow manual update, but doens't update with server's package.
Maybe I've missed some other variants.
I want to know what would be true python'ic and php'ic way to do this. Thanks.
I've decided to create separate PHP package for my PHP library, and upload it to a packagist.org, so, user could get it using php composer, but not forced to, as it would be in case of including library.php into python package.

Unable to install Wordpress plugins on Heroku

I installed Heroku on Wordpress by using the guidelines from https://github.com/mhoofman/wordpress-heroku. The system works fine. Only when I try to install plugins I receive the error message
Abort class-pclzip.php : Missing zlib extensions.
The error message is clear, zlib missing. I was just wondering if anyone of you had the same issue and can provide some best practices how to solve the problem?
It seems that heroku does not allow you to create files and you have to extract plugins and themes locally inside their folders respectively and push your changes back to your heroku repository. From the wordpress-heroku documentation:
Because a file cannot be written to Heroku's file system, updating and
installing plugins or themes should be done locally and then pushed to
Heroku.
Heroku does not allow you to modify files. You cannot use the backend of Wordpress to do those things if the site is hosted on Heroku. You have to install locally and then deploy. There is a good tutorial here:
http://wptutorialguide.com/wordpress-on-heroku/

Custom installer to install a PHP web site?

Just a quick one about installing a PHP website, are there any tools out there that would allow me to create an install package to fully install this website on a Windows platform? If possible maybe even take details like company name and database connections which then maybe updates the necessary PHP files?
If the later cannot be done its fine, but a free tool for installation would be great!
Thank you!
Ash.
It's possible with a tool like innosetup.
It let you build setup , in which you can put what ever you want (webpage , other setup ...).
If you want to do something a little bit advanced (installing apache , configuring file ...) you will need to do some code (delphi) , but the documentation is pretty clear about all the possibility.
Don't be fooled by the simplicity of the tool , it's very powerfull. For example you can check if a specific service is running to lauch (or not) a specific part of your setup. (if httpd is running just copy the webpage a skip the apache installation for example).
You can combine innosetup with server2go
Download the package you want as a .ZIP file, extract it, put your website in "htdocs" folder and then create an installer with innosetup.
Edit: You can edit pms_config.ini too with your needs.

Why does PEAR get installed to my user directory?

I am new to Linux and I am attempting to install the PHP PEAR library on a virtual server which is running Ubuntu. I am following a tutorial that covers installing PEAR but have run up against an area where I am confused. When running the PEAR installation program I am prompted as to what I want the INSTALL_PREFIX to be. Evidently the INSTALL_PREFIX, among other things, determines where PEAR will be installed. The tutorial suggest the value of INSTALL_PREFIX be the following path ...
"/home/MY_USER_NAME/pear"
where MY_USER_NAME = my user account
Having come from a Windows world, applications are installed on the system where everyone can use them. If I install PEAR underneath my user directory will other developers on the system be able to make use of PEAR in their PHP scripts? I want to make PEAR available to all users and not just myself.
Could someone explain to me the difference between installing for all users and installing just for myself? Does the install location matter? Should I be installing PEAR in a different location?
Thanks for any suggestions.
P.S. The tutorial I am following is located at the following URL ...
http://articles.sitepoint.com/article/getting-started-with-pear/2
Amend your INSTALL_PREFIX...
typically PEAR gets installed to /usr/share/php/
Have you read through the install section on the PEAR site?
There is no law against giving others access to your home directory but in practice it is never done. If you wanted to do that you would have to set the correct directory permissions and the other users would need to put your stuff on their PATH. But don't, it's bad if only because others can see all your stuff, accidentally (or maliciously) delete things, etc.
You should read a few things on file system standards and file system hierarchy and figure out what is appropriate for you system. Usually it will be something like /opt or /usr/local which will be accessible to all users. Usually you will need to have root permissions to install in global locations.

XML/Parser.php installation

I recently signed up to shared web hosting with godaddy using Linux and PHP 5. I want to work with multiple RSS feeds. I previously had this all functioning under Apache, however, the host supplied the PEAR installation. Now I have to do this myself and I am in unfamiliar territory.I installed PEAR PHP and managed to get rss.php in the pear directory. It now asks for XML/Parser.php and I do not want to spend another week finding where and what to do.
Can you please inform me where i can find this routine and whther there is any problem in just copying it into the PEAR directory with ftp?
You can always just create some subfolder in your project and extract any PEAR libraries directly there, it's just plain php scripts. You will have to add that folder (and subfolders) to your include path so everything will be accessible.
It is considered as a bad practice because you will have to manually update PEAR libraries and stuff, but it gives you independence from your hoster.
Your PEAR (or other libraries) classes can be anywhere. You just need to set correct include paths where script will search for required code. If you can't access php.ini, you can get include paths by using get_include_path() function and set them using set_include_path();
I highly recommend SimplePie feed parser over the PEAR::XML_Feed_Parser. Usually the PEAR libraries are great but they don't support several common types of feeds (I believe Atom 0.3 among several others). Also there is very little documentation about how to use it and (clearly) how to install it.
Simply include the SimplePie library and point it at your feed and it does the rest. It's easy to query for any data you want regardless of schema differences. It's also very fast, we're using it to aggregate hundreds of feeds over at http://www.feedscrub.com.
Hope that helps!
echo ini_get('include_path');
This should show the include the path to PEAR on the original host environment, from there if its not to big just wrap the entire mess up with tar -cjzf devPear.tar.bz path2pear/ .
Copy this tar file over to GoDaddy, extract to a safe location... then in .htaccess or at the start point of your application scripts, add this pear package into your include_path.
Alternatively:
If you have administrative rights, I believe there is a pear.php command called "installed" that shows all installed pear packages. If you also have pear administrative rights on the new environment, you can go down the line doing copy and paste of the package names you need to pear --install "package" name.
The second is a little cleaner, but the first will be faster... just accept these packages will be effectively stranded from the pear system and unable to be updated.

Categories