During the past two years I have built an App Engine application in Python. Soon it will be possible to use PHP on App Engine. I would like to use off-the-shelf PHP applications such as Wordpress, Mediawiki and phpBB together with my Python application. To the user it should be transparent which of the two applications (Python or PHP) she is using for a particular page. I consider the Python application to be the main application where I will do most of the programming. This is because I have more experience with Python and also because I already have written a lot of reusable code for App Engine.
Currently my approach is to build a proxy in Python that maps HTTP requests like this:
http://www.yellow.com/blog/* to http://phpapp.appspot.com/wordpress/client1/*
http://www.yellow.com/community/* to http://phpapp.appspot.com/phpbb/client1/*
yellow.com is a domain mapped to my Python application.
http://www.blue.com/wiki/* to http://phpapp.appspot.com/mediawiki/client2/*
http://www.blue.com/* to http://phpapp.appspot.com/wordpress/client2/*
blue.com is a domain mapped to my Python application.
Besides the blog, community or wiki, there are a lot of URL's that don't require PHP. These URL's are handled by the Python application. For example: http://www.yellow.com/admin/*.
I'm still struggling with the proxy to get the passing of cookies between the two applications right, but I think it's possible to do this.
It would be awesome if I could get it to work this way. However, it seems to me this is not the most elegant way to handle this. I know I could use subdomains to serve the PHP applications, but I would rather just use URL patterns. Also, with the proxy approach, I can tweak the returned HTML by the PHP application before serving it to the user. Another advantage of this approach is the ability to cache the pages from the PHP applications in memcache.
I would like to hear what you think of my approach to use Google App Engine (custom) Python and (off-the-shelf) PHP applications together. Will I run into problems with the proxy (Javascript, cookies, ...)? Would it be better to build everything in Wordpress, for example, with custom plugins written in PHP (the plugins could fetch data from the Python application)? Other suggestions?
Your use case is a good example of what Appengine's Modules are intended for. Take also a look at the dispatch mechanism.
Related
I have no experience in Ruby on Rails. I employed a developer to create a tour booking system for my site (php codeigniter). He developed it using Ruby on Rails in heroku and then linked to it by iframe in my front end.
Problem is
MS explorer doesnt display it,
issues with dynamic booking form sizing,
Cookies for the cart doesnt work as it's cross site and in iOS sometimes the security denies the cookies so system doesnt work,
Site massively slowed down due to the http requests.
Is there a way to convert the ruby system into php so i can just have it on my local site? Can anyone think of any other solution if not??
thanks
Unfortunately, there is not easy way to convert a language to another, with some exception (like language that compiles to another one, for example CoffeeScript to JavaScript). Using iframes will create security problems, which in turn trigger (modern) browser to block them.
So, what are your options?
Use the Ruby & Rails website as a subdomain of your main. Example, if your site runs on chambers.com and that the Ruby on Rails site is about invoicing, it could be on invoncing.chambers.com, and you could use links from one to the other
Rewrite either the Ruby or the PHP part, depending on size & team capability
I want to build an app using ExtJS 4 and PHP.
I will follow the MVC pattern with ExtJS 4.
However, I want to use RESTful webservices with PHP.
Yet I am not sure how to proceed.
How can I call for Web Services that are PHP functions?
How am I going to give the directory like structure to my links?
You can obviously use Ext.Ajax.request() to craft any RESTful URls that you want. However, be sure to check out the REST proxy that's built into Ext JS's data package. By connecting this to your store/model, you can dynamically generate RESTful URLs which can be used for the vast majority of your generic CRUD operations.
RE: the PHP side, that's a big question. Fortunately, there are literally a billion turtorials on creating RESTful services in PHP, so I'd dust off your Google-fu and start there. Here's a very simple introduction that just happens to use PHP: http://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340
You are most likely looking for Ext.Ajax.request.
There are some examples of Ext.Ajax.request from this stack overflow article.
I'm thinking in create a webapplication with cakephp but consuming python's appengine webservice. But, to install cakephp etc, I need to configure the database. Appengine uses another kind of datastorage, with is different from mysql, etc.
I was thinking in store the data in appengine, and using the python webservices, and with the cakephp application comunicating with the webservice, for insert and retrieve data.
Is there any good resource for this, or is it unpossible.
Obs: also opened for a possibility for developing the webapplicaiton completely in python running in appengine. If anyone has a good resource.
Thanks.
I think that you should try different solution: http://aws.amazon.com/simpledb/
It appears that CakePHP is a MVC framework that's very similar to django, which is included in app engine for python. I'm not sure why you would want to store your data in google app engine, unless you're dealing with an extremely large amount of data, in which case you're likely comfortable enough working in python to just make the app work entirely on GAE.
See the official docs for more info:
http://code.google.com/appengine/docs/python/overview.html
http://code.google.com/appengine/articles/django.html
What you can do is run your CakePHP app on a standard LAMP web host and access the GAE Data Store through a REST or RPC web service. This isn't such a bad idea if you already have a CakePHP front-end that deals with RPCs in the backend, but if your Cake app stores all it's Models in MySQL it could take considerable effort to adapt it.CakePHP Models abstract their storage method using the DataSource class. You might be able to find a DataSource class that uses REST or RPC. However, if you don't have a very considerable investment in CakePHP Controllers and Templates I would suggest simply building your app entirely in GAE
You can not run PHP on GAE. If you run PHP somewhere, it is a bad architecture to go over the internet for your data. It will be slooooow and a nightmare to develop in.
You should store your data where you run your php, unless you must have a distributed, globally scaling architecture, which afaiu not the case.
There's a detailed tutorial on getting CakePHP up using the PHP runtime that Google recently announced. http://aymanrb.blogspot.com/2013/05/cakephp-deployment-on-google-app-engine.html
I'm trying to develop an application server that will deliver content to a core group of websites, as well as provide third party services to other websites that also want to use this content. The app server will be hosting web services for these core + 3rd party websites. Authentication and all that comes into play. The data itself will consist of millions of records.
These records will come from a variety of sources: APIs, RSS feeds, REST services, etc. This app server will essentially collect this data on a routine basis, and update the database with this new information. This data will then be shared via some sort of web service (most likely REST) to the core websites and 3rd party websites.
FYI, I'm making a distinction between core sites and 3rd party websites because there will be different access levels, i.e. a core website will have more access than a 3rd party website.
All that said, I'm trying to make the best decision on which framework to use. At the risk of losing all credibility, I currently have a ton of this code written as a wordpress plugin. What started as a one-time site evolved into several sites, and some homebrew hacking to make my outdated infrastructure work across multiple sites.
I'm looking to migrate all of this to a new application server, with a solid framework.
Since everything is written in PHP, obviously I'm tempted to do the migration in PHP. However, I'm considering Python because of its powerful ability to manipulate data. I don't know if it's worth the hassle, though, of rewriting a lot of code in Python.
Could anyone give me some tips on what I should do? I'm really looking to clean up a big mess more than anything, and would like a framework to encourage some solid programming conventions.
All of the frameworks that you mentioned are capable. Pick one in the language that you know the best and use that.
I agree with #gpojd's opinion. All of them that you mentioned are fully capable.
However, it looks like they are too powerful for your job. Because they are all full-stack MVC-like web frameworks shipped with ORM, Template engine, URL redirections and i18n supports.
So, I suggest you to use more lighter/thinner frameworks. and if you don't mind choosing any programming languages, please check out the below frameworks.
Python
Werkzeug : http://werkzeug.pocoo.org/
Javascript
node.js : http://nodejs.org/
with Stylus framework : http://expressjs.com/
I work for a small tech start-up, and our main site is built on the CMS Drupal, which is a PHP-based CMS. However, I know some Python and would like to develop web applications to integrate with the website and allow users to interact with them.
How would I go about doing this? Does anyone have any experience or knowledge? Any particular module/script/etc that allows using Python or calling Python from PHP or Drupal?
If you are developing a web application nothing stops you from using Python and making it accessible from a subdomain or path not used by drupal, just have the web server point to it. Ex:
http://mainsite.com/ <- drupal
http://app.mainsite.com <- python web app
http://mainsite.com/python/ <- python web app
This is fairly straight-forward with most web servers. Django might be particularly well suited for this, it has a nice feature which can inspect live databases, and generate models for you:
python manage.py inspect.db > models.py
Which lets you interact with your existing database from Python with a nice ORM.
If you need to literally call Python from a PHP page, you can use zeromq for fast IPC or TCP communication, or build a simple REST API, etc.
There are several different ways to do integrate Drupal with external applications, but your best bet is probably installing the services module in Drupal, and make calls from your Python app over HTTP, just as you would interact with a remote server.
Some other options:
Interact directly with Drupal's database, rather risky as Drupal's database structure can change significantly with module upgrades or even configuration changes.
Place the Python app within an iframe of a Drupal page, giving you Drupal's design, though no functional integration.
Use JavaScript as a client-side middle-man between Drupal and Python.
Use command line as a server-side middle-man between Drupal and Python. Drush would be useful here.