packing a php self contained executable with my application - php

I am building a mac application using Xojo framework,
the app i am building have to run php as a command line, i could use the php that ships with mac osx
however i need a php with mcrypt extension, and the one built into the osx does not have the mcrypt and i don't want to force my customers to update their php,
so the optimal solution that i could think of, is to pack a php self contained executable with my application
is this possible? and how to go for it?

Yes, sounds possible.
In the Xojo IDE you could insert a Copy Files build step after the OS X build that copies your php executable into the resources folder of your built app.
Then in your App.Open you could copy that executable to wherever you want to from that SpecialFolder, or just reference it as is in your command lines depending on whether there are any restrictions imposed on how your are distributing the app (i.e. App Store).
Check out http://docs.xojo.com/index.php/SpecialFolder for some guidance on where to copy any files you need to bundle or how to reference them.

Related

PHP formatting in VSCode on remote Workspace without using Composer

My Setup: Ubuntu 20 with PHP and Composer
My Editor: VSCode with SSH FS extension to access remote workspace.
My Task: do some PHP stuff, mainly Wordpress Themes
My Problem: no PHP Formatter extension works on the remote Workspace
I tried to use: PHP-CS-fixer, Prettier with PHP plugin, phpfmt, phpcs, PHP Formatter...
Some of them will even not work on my local Workspace.
I can't install new Code on the remote Server (Composer), so i need a way to format PHP files just out of the Box like HTML or JS.
But meanwhile i think, this is not possible.
Solution: use Ubuntu to connect to the server and mount that folder in workspace, let VSC think it is a real local folder :-)
The problem with most formatting extensions is that they expect the files to be on a local drive, as in being mounted outside VS Code, including network shares by any NodeJS program (and therefore VS Code extensions). The extension uses the extension API's FileSystemProvider to provide FS access to VS Code. It is only recently that they added a way for one extension to use file systems provided by other extensions, and it's even more recent that they started pushing extensions to make use of this.
Sadly enough, not every extension developer might start using it, and it's especially tricky for extension that use native/external programs. That includes most language-servers and formatters.
For your use case, there are two solutions though:
Mount the folder on the OS level (e.g. sshfs) and just open it as a regular directory in VS Code, as another answer suggested
Use VS Code's Remote SSH, which actually runs the extensions on the server, therefore skipping the whole "files aren't on a local drive" problem

What is the easiest way to distribute a PHP extension written in C

I created an extension for djondb, it's a wrapper of the library which is a C++ Library, I compiled it and it's available to be downloaded from djondb site, I'm not an expert on PHP and I've been having some problems with the distribution, mainly I realize that I need to do each compilation for each platform and create an installer for each one, which is time consuming, what I want it's a to ditribute the source code and allow the user to install it in the easiest way,
What I already tried:
Using phpize, configure, make, sudo make install the user can install the library very easy on Linux and Mac, the problem with this is that users need to have g++, make, etc installed on their computers, and this process of installation does not work on Windows.
Compile for each platform (Linux x86, x64, Mac, Windows, etc), and upload each tar.gz to the site, the user download it and place each file in the correct folder. the problem here is that the configuration is too manual and the users tend to miss some step, and it's not user friendly. The other problem is that I need to compile each version using a virtual machine and that's time consuming. (Now I'd to include versions for PHP 5.3 and 5.4, this means 8 virtual machines to create all the binaries)
I tried to create an account on PEAR but the registration screen always said that I dont need an account for the purpose I'm creating... (seems that it's a common problem in PEAR system but didnt find how to create the account to propose the package).
Did a proposal on PECL but nobody answered to the mailing list, seems that it's very common too.
So I'm stuck at this moment with the 1 and 2 ways to distribute, what is the best way to distribute a PHP extension that is created using C++ in a user friendly manner and easy to install?
Thanks in advance, you can see the code of the project at https://github.com/djondb/djondb_phpext if you have more questions about how the project is structured or the full explanation of the phpize/configure/make process.
Take the middle road: Distribute the source for Linux / OS X users, who can build it themselves, and offer compiled DLLs for Windows users. That will at least limit the number of versions you need to compile.
As a PHP developer who maintains the extensions we use in our company, it is PERFECTLY fine to give only the source code and expect the users to compile it on their machines.
If you want to be nice, compiling a version for each machine you support yourself, is also an accepted way (See Zend for example) and leave it somewhere easy to download (like sourceforge/github etc).
Then, just listen to the users and improve your (release) system as you go.

Installing PDFTK on a shared web server

My web sites are hosted on Total Choice Hosting using some kind of Linux (I don't know what precise variety) and Apache. I don't have command line access - I can run command line programs only via exec() in PHP, or via CRON jobs.
Can I install and use PDFTK on a system like this?
If so, what exactly do I have to do? Which files do I have to copy where? Do I have to rebuild PDFTK from source, or is there an executable version somewhere?
Since (as I understand it) PDFTK is based on iText, which is written in Java. Maybe I'd be better off using the original iText package?
Or is there a better way of doing what I want to do (which is basically to merge and flatten a PDF file (blank form) with a FDF file (field values) into a new PDF file (the completed form) and download it to the user)? Is there some native PHP or Python or Perl code to do this?
Thanks - Rowan
A quick glance reveals that the PDFTK source is C++ and it looks like they use GCJ to compile some 3rd party Java code to native code. If you find a pre-built version of PDFTK that matches your OS and architecture you should be able to just upload the binary to your system and run it from PHP using exec. There are some builds available on the install page.
There are some native PHP libraries available for creating and manipulating PDFs. Check out TCPDF, Zend_Pdf, and FPDF to see if any of those are usable. Each one should support what you want to do, its just a matter of choosing the right solution.
Using PDFTK may be the fastest option since it is compiled code, but it is the least portable option since it would require the server have that software installed on it, where the PHP solutions could be distributed with your code.
If you are on a shared host you cant install PDFtk because you don't have access to root to install anything. You need to have a host that has it preinstalled. I use bluehost.com but there up-time is not the best. It works for now but I am going to move to another host once my site is complete. I have had several outages that have lasted for over a day.

How to bundle a php application with 1 click run/install

I create php application for small businesses. Some of the clients may prefer running the app on a local server, therefore my requirement is to create/bundle an app with apache/mysql/php with all the necessary confirguration and one click executable (be it a batch file) such that when the user opens it, it runs the apache server on some port say localhost:1234 and mysql as well.
and opens up the application in the default web browser.
To be more exact, Im looking for something like http://www.simpleinvoices.org/go, check their Simple Invoices for Windows which come budled with apache/php/mysql.
P.S - Im not sure if this question should be at SO or Superuser.
If you actually want to install a web server and a SQL server then Lars' solution would be a way to go. On windows you can generate a .msi installer containing the dependencies you need (like WAMP). An installer executable would be a cleaner solution than a batch file in my opinion, as it will also provide the user with an option to uninstall your software if they wish.
If you want to distribute your application in a standalone version, then you might also want to check a solution like NuSphere's PHPDock - http://www.nusphere.com/products/phpdock.htm
I had the same challenge and came across Uniform Server:
http://www.uniformserver.com/
You download it, add your application to it, start it and everything runs. Lovely.
Superuser would have been better. But depending on your requirements, you should just create a package to install. On windows, package it with WAMP, on linux, package it with either one-click-install or creating packages for the two biggest systems, namely APT and RPM. With the dependency-system on all of them you can make sure, that your application runs right off the bat.
PHP Desktop is the best option I found when researching this.
https://github.com/cztomczak/phpdesktop
PHP Nightrain is also an option:
https://download.cnet.com/PHP-Nightrain/3000-10248_4-76169308.html
Bitnami WAMP stack looks good as well:
https://docs.bitnami.com/installer/infrastructure/wamp/

How to compile an iPhone application source code on server using command line in Windows?

I have an application in which I change the data on web and then download the files then I compile my iPhone app with data. I just want to create ad-hoc distribution so I have already added devices. So is there a way that anytime I change data on web then I compile my iPhone app over the server using PHP and some command-line script so that I create a ready-made ipa and user can install the application using iTunes? Also is it possible to compile on Windows?
Also how do we change ad hoc provision profile? I mean where we can set code sign?
How do we invoke terminal and run command xcodebuild using PHP? Suppose we have mac server then how we invoke terminal and then navigate to project directory and run xcodebuild command?
Check out the OS X commandline program xcodebuild. When your current directory is the project directory (the one with the .xcodeproj file), xcodebuild will compile the primary target. See man xcodebuild for more options.
have you thought about setting up a build server with different scripts that can perform the requirements that you are asking for and of course a Web Interface to interact with it ?
This link describes how to do it, and in the comments of the blog readers mention several other Build Server alternatives with Xcode Project support.
Sorry if this is not the exact answer that you are looking for, but may be a valid angle to solve your problem ?

Categories