ColdFusion and PHP in same Flex application - php

I am working on a web application in Flex.
I have already used PHP as a "Flex Server", but now I need to add a mailing service and it seems that ColdFusion is the perfect tool for it.
I don't want to waste time and rewrite all the PHP services to ColdFusion, so I am wondering if it is possible to have PHP and ColdFusion in the same web app.
In the project properties for Flex Server I can only choose PHP or ColdFusion but not both.
Can I somehow manually connect to ColdFusion?

In the project properties for Flex Server I can only choose PHP or
ColdFusion but not both. Can I somehow manually connect to ColdFusion?
The Flex Server option is really meaningless in Flash Builder. I think it helps Flash Builder find the services-config file. I always leave it blank or select none and manually specify the services config file as a compiler argument.
I assume you are using AMF / Flash Remoting; is that correct? You can find the services-config file that is currently being compiled into your app and modify it to add a new destination for ColdFusion services. You may want to combine your current services-config file with the one that comes with ColdFusion.
You should look for the CF Serivces-config file in a directory similar to this:
C:\JavaServer\servers\CFInstanceName\cfusion.ear\cfusion.war\WEB-INF\flex
It'll be slightly different if you're using the standard edition of ColdFusion instead of the multi server edition. I'm not sure where to find the PHP config file; but the two files should be very similar.
Of course, I assume that PHP can also send email relatively easily and I'm not sure the short-term gains of building this will outweigh the long term headaches of dealing with two technologies side by side.

Related

PHP as independent application ( binary, compile, pack, no php on host )

If I would like to distribute PHP application with installer(package system of OS) how should I proceed? I don't want PHP files to be there, just working application, so when I type 'app' into console, it ends up being launching application, without need to install PHP on system(no php installation on host required). I would also like the application to have patch-able byte-code, so it's in parts, loaded when needed and only part needs to be replaced on update.
What I would do now is following:
->Compile PHP with extensions for specific platform.
->Make binary application which launches '/full/php app' when app is launched.
->Pack it in installer in a way, that there would be binary added to path when added, launching specific installation of PHP which is alongside the app with argument of start point->App would be running.
Problem is:
Maybe I don't want my PHP files to be exposed(in application, there will be available source anyway) is there some ready made stuff to do this? Is there some better way than I proposed?
Alternative: Modifying OP Cache to work with "packing" application to deliver byte codes to modified OP Cache which just reads the cache.
My suggestion would be a tiny tool I just finished, for almost exactly the same problem. (Oh yes I tried all the others but they're old and rusty, sometimes they're stuck with 4.x syntax, have no support, have no proper documentation, etc)
So here's RapidEXE:
http://deneskellner.com/sw/rapidexe
In the classical way, it's not a really-real compiler, just a glorified packer, but does exactly what you need: the output exe will be standalone, carrying everything with it and transparently building an ad-hoc runtime environment. Don't worry, it all happens very fast.
It uses PHP 7.2 / Win64 by default but has 5.x too, for XP compatibility.
It's freeware, obviously. (MIT License.)
(Just telling this because I don't want anyone to think I'm advertising or something. I just took a few minutes to read the guidelines about own-product answers and I'm trying to stay within the Code of the Jedi here.)
However...
I would also like the application to have patch-able byte-code, so it's in parts, loaded when needed and only part needs to be replaced on update.
It's easier to recompile the exe. You can extract the payload pieces of course but the source pack is one big zip; there seems to be no real advantage of handling it separately. Recompiling a project is just one command.
Maybe I don't want my PHP files to be exposed(in application, there will be available source anyway)
In this case, the exe contains your source compressed but eventually they get extracted into a temp folder. They're deleted immediately after run but, well, this is no protection whatsoever. Obfuscation seems to be the only viable option.
If something goes wrong, feel free to comment or drop me a line on developer-at-deneskellner-dot-com. (I mean, I just finished it, it's brand new, it may misbehave so consider it something like a beta for now.)
Happy compiling!
PHP doesn't do that natively, but here are a few ideas:
Self-extracting archive
Many archival programs allow you to create a self-extracting archive and some even allow to run a program after extraction. Configure it so that it extracts php.exe and all your code to a temp folder and then runs ir from there; deleting after the script has complete.
Transpilers/compilers
There's the old HPHC which translates PHP code to C++, and its wikipedia age also contains links to other, similar projects. Perhaps you can take advantage of those.
Modified PHP
PHP itself is opensource. You should be able to modify it withot too much difficulty to take the source code from another location, like some resource compiled directly inside the php.exe.
Use Zend Guard tool that compiles and converts the plain-text PHP scripts into a platform-independent binary format known as a 'Zend Intermediate Code' file. These encoded binary files can then be distributed instead of the plain text PHP. Zend Guard loaders are available for Windows and Linux platform that enables PHP to run the scripts encoded by Zend Guard.
Refer to http://www.zend.com/en/products/zend-guard
I would like to add another answer for anyone who might be Googling for answers.
Peach Pie compiler/runtime
There is an alternative method to run (and build apps from) .php source codes, without using the standard php.exe runtime. The solution is based on C#/.NET and is actually able to compile php source files to .NET bytecode.
This allows you to distribute your program without exposing its source code.
You can learn more about the project at:
https://www.peachpie.io/
You've got 3 overlapping questions.
1. Can I create a stand-alone executable from a PHP application?
Answered in this question. TL;DR: yes, but it's tricky, and many of the tools you might use are semi-abandoned.
2. Can I package my executable for distribution on client machines?
Yes, though it depends on how you answer question 1. If you use the .Net compiler, your options are different to the C++ option.
3. Can I protect my source code once I've created the application?
Again, depends on how you answer question 1. Many compilers include an "obfuscator" option which makes it hard to make sense of any information you get from decompiling the app. However, a determined attacker can probably get through that (this is why software piracy is possible).

deploy website without source code

I have developed website in php. I want deploy it without source code. Is it possible with php?
Can I convert my website code to some intermediate form and then deploy it ?
You can use the Zend guard to encode your code so it can't be reverse engineered...
http://www.zend.com/en/products/guard/
PHP HTML and JavaScript are open source language so you can do nothing to encode them which can't be decode. One way is Zend Guard - Encode Your PHP Applications for php which can be decoded by sites like these: Websites for zend decoder online.
But the good news is if you always use the last version of Zend Guard
it can't be reversed, because still there is no decoder came for it.
Another way is, you buy a VPS (Virtual private server) or Dedicated Server and deploy your source code in there and you just sell your web application usage to your customers (not the source code). So just, you have the user and password of host and no one can see your application code.
Update
Recently, I've used ionCube. It's fine. However you need to change your deployment process a bit. Before transferring code to deployment server you need to encrypt it by ionCube. After that you should install ionCube loaders on the server by which php can load the encrypted codes.
if you are going to host your website on shared hosting or any thirdparty hosting, you may use zend encoder or ioncube php encoder, they will protect your source code.
http://www.zend.com/en/products/guard
http://www.ioncube.com/sa_encoder.php

Convert PHP-MySQL web application to desktop app (exe)

I have developed a PHP-MySQL web application, which is a school-based project.
My client wants this application to be converted into a .exe file such that it can be installed on his desktop and use it.
How the PHP website can be converted to a .exe file and can it be run without the need of a database/server software?
Please advice.
The convenient solution is not to convert the website to .exe. I think it will be better if you have portable server/php/mysql and make the website work from a usb or CD with autorun.
NuSphere's PhpDock claims to do this: It serves as a deployment helper and comes with a bundled web server. However, I don't know about the database part, and it's not free.
PhpDock enables you to deploy any PHP web application as a Stand Alone Windows Desktop application w/o any changes in the code.
I don't know that particular product, but I have been using their IDE for years and am quite happy.
try using a site-specific browser. it will make a desktop app that is basically a portal running to your webapp. try this one:
https://mozillalabs.com/prism/
It allows alot of advanced features like system tray icons and such. I have used it many times!
Hope this helps, JL
Short answer: Not possible.
Long answer: It depends.
You could install a web- and database server on his machine (or create an installer that does it) and run the application locally on his machine.
or
You keep the application on a server and just provide a launcher that opens his browser and points it to the URL of the application.
As Artefacto mentioned, it might be a good idea to switch to SQLite instead of MySQL but depending on how your application is written it might require a lot of code and SQL Query changes.
No. You have at least to remove the dependency on MySQL (and use e.g. sqlite instead).
Then, you would either have to:
Convert the webpages to windows dialogs. This would completely change your application (e.g. what would originally be http "form submissions" would be someting completely different). At this point, it'd much easier to write a .NET application
Bundle a web server (e.g. Apache) with PHP installed.
Another try would be to turn your php project into PHP-GTK (http://gtk.php.net/).
Yet another one is to give HPHP a try (https://github.com/facebook/hiphop-php/wiki/) and try to turn the generated C code into something like a .DLL in .NET and use it for the logic while coding the UI in say, C#.
Just create a simple program in C or C++ that will just add icon in Start menu, desktop and Quickstart. If your client clicks the icon it will open the default OS browser and point it to URI of your application online.
That might fool your client :)
Or maybe it will be enough for him (he might be asking you to convert it to exe because he can't remember URI or something - ask him what is the reason).
You can use xampp open-source project to pack your PHP site into an executable file.
Use the following steps:-
1. Download Xampp source code.
Add your PHP file inside htdocs directory(Ref:- https://sourceforge.net/p/xampp/code/HEAD/tree/win32/xampp/htdocs/).
Now compile the XAMPP source code and distribute it.
For DATABASE creation and initial data loading in the database, you can code your site in such way that if database is not created, it redirects the page to install.php which do the database creation and data loading task using sql file provided(you need to add SQL file containing database structure and required data).
Don't forget to delete the SQL file post installation of database.
Not sure that's gonna be possible but have a look at:
WinBinder
WinBinder is a new open source
extension for PHP, the script
programming language. It allows PHP
programmers to easily build native
Windows applications.
(source: winbinder.org)
Solution 1:
There are several solutions to convert your web application into a desktop application, the one I prefer is the open source solution: PhpDesktop, but unfortunately it only supports SQLite.
Best Solution:
To convert your PHP application with MySQL I know a paid solution that does this: 'ExeOutPut For Desktop', it is the best for this job
Php desktop is the way to go, it's actually very simple to modify to the version of PHP you want to use and is open source too https://github.com/cztomczak/phpdesktop

Transform my Flex application into Adobe Air. Running a PHP in Air

I'm a newbby in Adobe AIR/Flex.
I have developed a simple Flex web app. that through 2 Php's, can connect to a DB and return an XML result of the query. I uploaded the PHP and Flex files to my internet server, and the app. works fine.
My question is:
How can I make the same app. work in Adobe AIR? In other words, I have made a new AIR project, and I copy/paste the Flex code. When I run the project, it does not work and say things like:
[RPC Fault faultString="Error #2070: Security sandbox violation: caller cannot access Stage owned by ." faultCode="Client.CouldNotDecode" faultDetail="null"]
at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:851]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:188]
at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
So I think that in my AIR app. I cant write HTTP services. Or maybe I cant use the php file that connects to the DB, makes the query and then return an XML.
How can I transform the Flex app. in an AIR app. Do I have to use the SQLConnect and that stuff? Cant I use my php's files that work well?
Thanks.
My regards.
Alan
You can write AIR applications that connect to your PHP, I use coldfusion and java so not exactly sure what differences there will be but should be none on the server side.
The AIR application will require access, or compiled with, the services-config.xml and the three files it includes. For my AIR apps it seemed like the "includes" in the servies-config.xml file did not work and I had to copy the contents of those three files into the main file.
On the compile line you will require something like:
-services "C:\Blazeds\tomcat\webapps\chat\WEB-INF\flex\services-config.xml"
(sorry, I develop on a windows machine), but you will require the full path to your actual services-config.xml file. That line is in my Additional Compiler Arguments with my locale option.
This also requires you to create the project with a server side option.
You might want to also look at moving the code into a separate project, and then have both your AIR and web app use that third project with the code. Then one change in the code can affect both version, of course that means everything would have to be recompiled.
PS. I found the Adobe AIR Programming Unleashed to be a good book for this information.

Making a distribultable standalone program in PHP

I've decided to code some applications in PHP that are supposed to run offline in the user's machine. However, I can't seem to find an user-friendly install wizard to create a local server in where the script will run. Any ideas?
PS: Here's an example of what I want: http://www.nolapro.com
You could go to the old school route and try using PHP-GTK.
Text Tutorial here: http://www.kksou.com/php-gtk2/References/Compiling-standalone-PHP-GTK2-applications-on-windows-using-PriadoBlender.php
or you could go the route that I believe has much more promise: Adobe AIR + PHP
It has the added bonus of running on any platform!
Video tutorials here: http://www.vtc.com/products/Adobe-AIR-PHP-Development-Tutorials.htm
There's also a new player in the game, Appcelerator. It lets you write your code in whatever language you want (PHP, Ruby, Python, etc) and compile it for the platform of choice (iPhone, Android, Windows, OSX). Parts of it are still beta, but it looks unbelievably slick & cool, and there are lots of tutorial videos. http://www.appcelerator.com
I hate to advocate this, because it just feels so wrong. You would probably be better off using a language inteded for use for stand-alone applications, if you're going to be doing this often or in a production setting.
With that said, a colleague of mine used to use the Bambalam PHP to EXE Compiler for this. He actually had a profitable product built around it.
Bambalam will generate an EXE that doesn't rely on any external DLLs, based on your PHP code.
http://www.bambalam.se/bamcompile/
If you have a webapp written, you maybe want to deploy on client, a possible way is use wapache, which is a standalone apache bundled with your application, and an integrated (IE) browser control inside.
http://wapache.sourceforge.net/
A new feature of PHP 5.4 & 6 can help you, the builtin web-server.
http://php.net/manual/en/features.commandline.webserver.php
With this feature you can host locally your php app without external webserver, and access on localhost.
If you really talking about a client application you are really wrong to do this.
If you want to wrap a server + browser to deploy your web based application so it runs local you might check out three options:
1) Deploy a simple webkit browser (you can get a QT Webkit Browser in 30 lines of code) and an apache server that is installed somewhere standalone (not via the apache control script as this uses port 80 and i probably conflicts with another installed webserver.
2) Look at the Firefox PRISMA solution. I have read about this only in a news article but it wrapps the firefox around one single start URL. You have to deploy a webserver in the same way as
3) Try to wrap it as a HTA application. Search the corresponding info on MSDN.
I would prefer (1) as you can add special application interacting code as needed.

Categories