OpenOffice in server mode with PHP on Windows - php

I am working on a project which requires me to generate documents as docx and then convert to doc and pdf.
This project is written in PHP (using Zend Framework) and running on IIS on Windows (client requirements - definitely not my choice!).
Windows Server
IIS 7.5
PHP 5.3
OpenOffice 3.2
I am researching the ways in which I can carry out the document conversion (including the LiveDocx service) and am currently looking into using OpenOffice running as a service to convert the documents.
I have a PHP script which works -- it is similar to the code in this post How do I convert RTF to PDF from my PHP web page using OpenOffice? -- but I wanted to know how well this will scale. the PHP script is basically a PHP version of the PyOD converter using PHP's COM functions. On this page (http://code.google.com/p/jodconverter/wiki/GettingStarted) it specifically says that the PyOD script is not intended for to work with multiple concurrent connections. I would therefor assume that the PHP script will be equally unsuitable.
Having read around, it seems that the OpenOffice process which is running will only support one connection at a time. Is this definitely correct? If so then am I right in thinking that it is simply not a viable solution? I would be expecting high usage for the product so concurrent conversions are a must. Does anyone have any experience with this in a production environment?
In finishing, does anyone have any other recommendations for carrying out the conversions? If not, I will go back to using the LiveDocx service. My only real gripes with it were speed and some inaccuracies with the conversions.
Thank you in advance for your help.

You probably can scale OpenOffice to do what you require. Having done work directly with the OpenOffice UNO api in the past, you might find you have a lot of work to do though. Trying to use a single OpenOffice process in a multithreaded-fashion only lead me to grief. You can however spawn several OpenOffice processes and single-thread each. It depends on what your performance criteria are as to whether this is going to be scalable enough...
JODReports and Docmosis sit over OpenOffice so it might be worth trying one of these systems out to see if you could potentitally scale to what you require before investing any development effort yourself with the particular technologies. You might also look at LibreOffice which has evolved a little further recently than OpenOffice.
Hope that helps.

Related

Installing ffmpeg for php

I've been searching the internet for over 3 days now and cannot find anything that has a clear explanation of how to install ffmpeg for php. I currently have ffmpeg installed correctly on my Mac command line but as to how to use it in my php scripts is beyond me. How do I install ffmpeg for php? Any help would be great. Thanks.
ffmpeg is a set of executable programs and not an API. There was a project I was aware of in the past that built a php extension, but it was not robust and never really emerged as viable for a number of reasons, not the least of which is that ffmpeg has a lot of different options and builds.
Several years ago I was tasked with building an audio and video encoding system for a social network startup, utilizing PHP as the middleware, so I've been through this exact exercise.
One of the most challenging aspects was coming up with a working compiled version of ffmpeg with all the encoders we wanted to have. In our case our hosted environment was AWS and we were using Amazon linux servers, so there were a few hiccups along the way, and patches I had to chase down. There were packages available that had ffmpeg, but they were hopelessly outdated and missing key features we needed. The only way to get things working was to get the ffmpeg source and compile it, along with the source for the various codecs we were using, primarily to get mpeg4 video and compatible audio. If you aren't comfortable doing this, you will probably not be able to get things working.
In regards to the PHP side of it, I ended up using the PHP-FFMpeg library suggested in the comment above, but I did fork it and made a lot of customizations that worked for us, but were not really contributable back upstream. Subsequently, the maintainer of the library has addressed many of the issues I had and it is a much more robust library now that should save you a lot of problems if you were to try and create your own wrapper.
In summary your server needs:
A working compiled version of ffmpeg and its associated helper
programs which may be of need depending on what you're going to be
doing with media you are producing. For example, there is a separate media introspection program (ffprobe) that is used to determine the characteristics of media you want to encode.
A PSR-0/Composer compatible project. Ours was built on top of Symfony 2.x but that isn't a requirement. I did want to mention it as the project has really pushed the improvement and stability of the symfony component that wraps the php 'exec' function at the heart of any effort to call an external program.
Following the instructions and reading through the API you should be able to get a sample encoding to work with PHP, but keep in mind that ffmpeg works with files, and there are lots of file related issues you have to think through (original files, rendered files and naming, temporary file locations) all of which you'll have to deal with unless you're doing something trivial. In our case these programs were async command line/batch oriented and there was a lot of time and effort that needed to go into figuring out a way to scale and be performant. Needless to say, encoding video can take a lot of time, and is not something you want to do in a monolithic php script where the end user uploads and then waits while you do all the processing in the same script!
I know you are trying to do this on your Mac. Is this really the target environment for your production deployment? This is finicky and platform dependent enough of a process that I don't think it's advisable to try and get a hacky version on your Mac, because the process of getting ffmpeg, and the exact version and components is highly variable and extremely important to your success.

Using libXL with PHP and mySQL

I'm working on importing and exporting very high volumes of data from Excel into/out of MySQL via PHP. I have a working solution but it is very memory intensive and slow.
I have seen that a developer has produced a Unix build PHP script incorporating libXL - a very fast C library for excel that costs about $200. This purports to process 10,000 cells in 0.03 secs using 262kb of PHP memory.
I also notice that someone posting on this site is developing a stand alone dll based on libXL which I don't think will be suitable for my purpose.
Questions:
Is anyone out there looking to produce a simple to implement PHP libaray built around libXL which I could deploy on both a local Windows based XAMPP rig and onto my UNIX based host (Hostpapa while I'm developing)
Would I need to buy libXL for both Windows and UNIX to work both locally and on-line
Are there any other PHP solutions which are very fast and have low memory requirements
I have tried every PHP solution suggested by the PHPExcel developer, Mark Baker (thanks Mark), and nothing meets my requirements fully so no suggestions along those lines please.
I am considering learning Perl so I can use the excellent Excel parser that exists but unfortunately I've got time constraints and I think that will take me too long.
I am using libXL for my requirements, which involve parsing large amounts of cells in linux, its well worth the money, and in my opinion none of other PHP Excel solutions can match this coz it is a compiled solution. You can find more info here:
http://www.king-foo.be/2011/05/a-first-attempt-at-the-php-excel-extension/

compiling PHP 5 to EXE?

i have been using the awesome bambalam: http://www.bambalam.se/bamcompile/ compiler to make exe from php source.
But it's getting old, and it doesn't support php5.
Is there another project that will do the trick?
Thanks
ADD1:
i need only for windows
Please note, this was answered before the OP added the vitally important "I need only for windows" addition to the question.
Well the way Facebook handle this is by compiling to an intermediary language, C++, via a piece of software called HipHop for PHP.
There's also PHC, and a few others. Zend Server caches the bytecode which helps a lot.
You can try exe output, get it here, www.exeoutput.com. It has amazing features supports html, flash, javascript, php, etc.
Give a try to one of these tools:
PHPFlexer, if you only have a single php file (like a quick commandline tool)
RapidEXE, if it's several files/folders; here you can even choose a PHP version
PHC-Win, it's the ancestor of PHPFlexer and works pretty well
ExeOutput, a big monster but it gives you a webserver environment and a nice GUI
ZZEE, despite its silly name it's pretty good but features some oldish PHP
The first 3 is command-line, the last 2 are able to develop a window-based application; but they're slow, sometimes a bit tricky to configure and they also make a big fat exe file that loads relatively slow (especially ExeOutput). Command line ones are pretty compact and easy to use, with an output exe around 2MB.

Python or PHP for small windows administration scripts?

I'm choosing between these two languages, in contrast to another question here. My program going to be set of scripts checking files, free space, checking that apps are running etc. and writing information to database. Then PHP web page will show results.
Python have more examples of winapi calls (at least at StackOverflow) and more attractive to learn and use in different areas of programming, but I didn't use it before. With PHP I have small experience and I will be using it for results web page anyway.
PHP seems to be easier to install on network (to use one network installation for many workstations). Both languages can work with COM objects (I will need ADO).
Scripts will be small, not complex, but their number will grow.
Can someone with experience in similar tasks advise on choice between these two?
Don't shrink from using a language just because you haven't used it before. Learning a new language is one of ways to expand your overall capabilities as a programmer. True, you won't be as productive with it at first but learning how the language tackles common problems (manipulation of data structures, creation and lifetime of objects, etc.) will teach you new ways to think about computing.
That said, I would suggest you use the ActiveState version of Python (http://www.activestate.com/). It has the Windows integration included. I'm not sure about network install with Python. I've installed it across a net by running a remote desktop of the target and running the installer. Windows wants things registered in the registry so running a language is not like running an .exe sitting on a remote file share.
I asked question first time as anonymous so have no other option to reply now except to write an answer.
Thank you verisimilidude for ActivePython advice!
Installed ActivePython at home, reading Dive into Python 3.
Installed RadPHP XE at work (company bought it).
So for work it will be PHP. For me, if have free time (and may be for kids, when grew and if interested) it will be Python.
As someone who uses both on a regular basis, I tend toward using python for windows scripting and php for web apps. It's mostly just my preference, but I think they're each ideally suited toward different things. I love using Python in windows, it is really versatile.
a ) python is a nice alternative because you can generate an executable, otherwise (running as script) php is more suitable because it does not required an installation.
b ) try to not to connect directly to the database. Instead, you can create a web page then the clients can connect to it instead to do a direct connection to the database.
for example in php (in the client)
$fp=fopen("http://192.168.0.200/update?id=mymachine&value=200","r");
fclose($fp);
ps: For api calls, both (php and python) can do the same. Thought, for php and Windows Vista (and higher) exist some restriction when you are running it as a apache-module and apache is running as a service but i don't think it is the case.

Running a PHP application in a desktop environment

I have been pondering about this for a few days, and I'm surprised this hasn't been done yet or isn't very popular.
What I would like to see was a way to run a PHP application inside a desktop application. For example, the application would need its own mini webserver that doesn't handle requests, but allows PHP to be run.
Sometimes I have been set with tasks that clients demand coded in C# or .NET, and I think to myself 'I could have this done so much quicker if I could use PHP'.
Does anyone have any information on this subject? And FYI I do know PHP is meant to be a web programming language and is not meant to be run in a desktop application, but I'm intrigued :)
PHP-GTK hasn't had a new version since 2008, but it may suit your needs.
http://gtk.php.net/ is exactly what you want. You will be using an old GTK version, at least until a new php-gtk version is released (which is expected soon, according to the main page), but even that shouldn't be a big problem.
Also, see http://news.php.net/php.gtk.dev, it shows there is still activity on the project.
If you mean console (command-line) applications then by all means you can do that. I do it all the time, both on Windows and Linux. Obviously you will not have web-server related variables ($_GET and so on) but other than that you have full functionality of PHP.
See this for details.
PHP installations come with two executables, one for CGI (common gateway interface) and one for CLI (command line interface). Just set up PHP on your machine and use the correct php.exe.
If you mean applications with windows then, like others say, there are frameworks for this, but I doubt this is a good idea.
Well if you write a simple shell in .NET, you can drag a web browser object into the desktop app and simply show a webpage inside there, without the browser controls (back, home, etc).
This is a bit hackish, if you want a desktop app, code a desktop app, you'd be surprised how easy it is in C#.NET. And obviously the PHP needs to run somewhere, either on an external website or a local web server (ex: XAMP)
I've done a couple of applications for a customer using miniPHP Studio for exactly the same reasons. Both me and the customer were happy about the result. Might take some time to get used to it, but it has a kind of a debugger built into the IDE and, being based on Winbinder, you can use its forum to pick up more code samples.
Stuff I definitely found out works well with it: PDO, MySQL, SQLite, cURL, mbsting, mhash, mcrypt, bz2, ADODb (after modifications), running external programs. Stuff I never managed to make behave: FreePDF, having the input fields accept Unicode characters.
For the future (read: as soon as I find some free time) I'm gonna take a look at Titanium. This one definitely looks as being actively developed and on a path upwards.
PHP Nightrain is a packager written in Python for the PHP Programming Language. Using this tool you can convert your PHP/HTML/CSS/Javascript application to a Native Desktop Application. Currently, PHP Nightrain supports the Windows, Mac (OS X) and the Linux operating systems.
Features:
PHP 5 Pre-compiled
Option to use your own PHP
GUI rendering your PHP/HTML Web Application
Set custom width and height
Start application Maximized if required
Start application Fullscreen if required
Window Title changes as the value of the title tag changes
executable for Windows
executable for Mac
.app file for Mac
executable for Linux
https://github.com/naetech/nightrain
http://www.naetech.com/php-nightrain

Categories