I'm currently writing an application that will extract data from a few different websites to be passed back to my app, parsed, formatted, and displayed. The problem I keep running into is being able to pass in and display the data in a graphical manner. I was hoping to use HTML5 to do this, and all of my scraping is set up in php. Of course, to draw in HTML5 requires using JavaScript, and getting my php output to JavaScript seems messy. Am I missing a better way to architect this solution?
It seems like a good way to me, as good as any, except it's not very backwards compatible, it might be better to do the graphing server side
If you want to do graphics directly in php you may want to look at using GD or ImageMagick.
Related
I want to make apps for iPhone and Android, but as an enthusiastic PHP-programmer, I'm not really willing to learn Java or C++. So I ran into PhoneGap.
BUT... I don't really like programming in pure HTML and Javascript either! (all those hooks, commas in JQuery etc. are just too messy, in my opinion...and I hate CSS too).
The way I use PHP now, is that I have written a quite advanced framework, that processes clean xml-templates into HTML/Javascript. This way I can make my own custom HTML-tags, that do all the work of CSS, extra HTML and it creates all Javascript for me automatically...
It's a bit how Delphi for PHP and Prado work. Once the (visual!) PHP-components are done, I can use them over and over again... and only have to think about HTML, CSS and Javascript once, while building the component...
Okay, now my question: since I can't use PHP on the client with PhoneGap, but DO need the HTML, would it be a crazy idea to let my web-server create the HTML for me the first time the app runs, then store the HTML locally using PhoneGap, and then the next time the app is loaded, reuse the locally stored HTML ?
So my question is : can I create HTML on a webserver, and then store that HTML locally so my PhoneGap-app can use that? Or is the HTML in a PhoneGap app somehow 'compiled' and cannot be changed afterwards ?
Or is this a really stupid idea and should I abandon my nice PHP-components framework? What are your thoughts?
It's hard to give a meaningful answer to a question like this without some context. The big question that you've left unanswered is: What are you really trying to do? What will the apps that you create do, and what will make yours different and better than apps that are already out there? Do you want to sell these apps in the app store? Are you trying to collect and/or disseminate mission-specific information for your company?
On the face of it, writing a bunch of HTML and PHP that'll execute on your server just to generate a bunch of HTML and JavaScript that'll execute in a PhoneGap application seems like a lot of trouble. OTOH, if that's what you're most comfortable with, and if you can get it to do what you want, go for it.
If you give your framework a catchy name and make some bold assertions about how it's the newest, fastest best way to develop mobile applications, you can probably turn it into a book deal. ;-) Until that happens though, you'll have a hard time finding answers to questions about writing iPhone apps using PHP.
I'm making a search engine that (in theory) analyzes online encyclopedias to get answers to a user's question from a form. However, I want to know if I'm wasting my time with the PHP. If I am, what language would be best suited to this task? If I'm not, what function in PHP would allow me to do this? Thanks!
PHP works as well as anything else. If you want to read data off of another webpage, you'll probably want to use cURL, which is built in to PHP.
All of the requisite pieces are there: PHP does fine with processing text and HTML. If you already know PHP, it's best to stick with what you know.
This is easy enough to do with PHP. If the sites you are getting the data from are valid xhtml it will be extremely easy to process the page and extract the data using the simplexml extension.
I want to change my HTML page as an image. Is there a way in PHP to change or save an HTML page as an image?
This is not easy; as NullUserException says in his comment, you would need to render the HTML page on the server-side, which is not something PHP (or any other server-sided language) has built in.
The approach that comes to mind would be to write a program (probably not in PHP, but rather something like C# or C++) that runs on your server, fires up a web browser, and does a series of screen captures (possibly combined with page scrolls). As this is a very nontrivial and bug-prone process, I would suggest looking into third-party components that are capable of doing this.
You would then execute this program from PHP, and when it's done running, display the results from the file it output.
I would advise you to use an external service with an api. This list might be a good start: http://blogs.sitepoint.com/2008/07/10/9-ways-to-put-site-screenshots-in-your-web-app/
Thumbalizr seems great, they allso provide a php script so you can cache the images locally:
http://www.thumbalizr.com/apitools.php
Try taking a look at browsershots.org - source code is available for it if you want to install it locally. Essentially it uses a browser to take screenshots, and can be controlled via an XML-RPC interface, which you can call from PHP.
As others have said this is not a simple job, and not something you can do directly in PHP, so use an external service.
(I'm not affiliated with browsershots.org in any way)
Looking to start a project that would require me to use Flash or Flex (I have not worked with either of these yet, yikes!!!). Flash would be the front end user interface that needs to display items pulled from a MySQL Database (I was thinking ajax via jQuery but open to suggestions). My question is, What would be the best approach for something like this?
High level
Flash calls to display image through ajax/php from Db
I don't know how to code the Flash part, any tutorials that kinda sound like what I'm doing? suggestions? thoughts? other ideas?
Side Note: The database table will contain text that describes the image being passed to flash, so I would like to display both the text and image.
Thanks for any advice/help,
--Phill
I'd recommend you try AMFPHP or ZendAMF. Both of these use AMF3 (which requires you to use Actionscript 3/FlashCS3+), and it is one of the quickest ways to get data into Flash.
You could also use php to generate an xml file and just request that url in Flash to load up the XML. You can also use ajax like you said, but it's probably going to be the slowest method open to you, unless you're working with very small data sets.
Regardless of the method you choose, I'd suggest you use Actionscript 3. It's much faster and if you use XML, it'll be a life saver.
Here's a tutorial about setting up flash to work with PHP & MySQL:
link
Have any bridge libraries been developed for PHP that provide access to the jQuery framework? Ideally it would be nice to have something fairly extensible so that creating jQuery-based content using PHP code would be fairly easy and customizeable. Does such a thing exist yet?
pquery
jqpie
jquery-php
There's a warmup list.
So far I've found one that seems to fit the description. I haven't tried it out yet, so if anyone has any feedback or experience with this or other ones don't hesitate to post!
PQuery
jQPie might be what you're after.
What can jQPie do?
Easily request and process data from php using $.getJSON
Inject php generated html into elements using $.(element).load
Call php functions directly from your web pages using $.jqpie
Call jQuery from php in respond to $.jqpie calls
Advanced autocomplete using jqpie_complete
QueryPath (http://querypath.org) is a full implementation of the jQuery DOM/XML/HTML part of jQuery. QueryPath has full CSS 3 selector support (including the stuff jQuery doesn't have, like XML namespace support). It also comes with DB tools, where you can run queries and have the results inserted into the query object. And it has a template engine, too. Like jQuery, you can write custom extensions very easily.
But it definitely takes advantage of its server-side status.
The main project page is at https://fedorahosted.org/querypath. You can download it there (and see lots of examples, including RSS and SVG manipulation).
Integrating with jQuery, then, can be done easily by sending XML data of many sorts down to jQuery. (You could probably send JSON, too... never tried.) And since the server side code and the client side code both look the same, there's less of a need to learn two totally different toolkits.