Connect AngularJs to local server php MySQL - php

Total beginner question (apologize in advance for the stupidity :( )
I am trying to learn how to develop apps using ionic framework/angular.
I created a simple news feed (UI part of it anyway).
I then installed MySQL, PHP and Apache on my Mac (MAMP). I have created some tables and inserted some dummy data.
Now, I am completely lost on what kind of routine/procedure to write on my server, and what code to write in my Angular service so i can show the dummy data in my app?
Basically, how do these two discreet "things" on my system know how to connect and exchange data?
I googled it for few days, but most tutorials don't seem to address this basic question.
I don't actually expect somebody to take me through the steps, but if you can point me to some tutorials/resources on this, it would be much appreciated.
Thanks in advance.

You will have to think in terms of web/RESTful services to expose data to your Angular app. I can point you to a couple of introductory tutorials on the MEAN stack (MongoDB, Express, Angular, Node), but you'll get the idea:
Learn to Build Modern Web Apps with MEAN
Mastering MEAN: Introducing the MEAN stack
Several references to online resources, by ericdouglas

Since you are using AngularJS, your frontend app is a single-page app I suppose. All data your frontend app based on is provided by your backend, here is PHP/MySQL.
You need to use PHP to create a REST service to provide JSON data, which can be consumed by AngularJS app. While MySQL is behind your PHP app as a storage provider, it doesn't talk to your AngularJS app directly.

Related

Sharing code between a Web Applicationa and an iPhone App

I posted this question a few weeks ago, but perhaps it came off as vague and wasn't really well accepted. So I'm going to try and be more specific, since I am still looking for an answer.
I have an idea for an iphone app that I wanted to start working on. I'm a Web Programmer by trade, and was considering writing the application initially as a website. (intended for Desktop / Laptop users). Once I figured out all the ideas, I was then going to use that as a blueprint for the iphone app.
My question is: It would be great to have both versions running, and thus, sharing as much code as possible. Is there a practice, methodology, or set of principals for dealing with this sort of scenario? For Example: www.facebook.com and the Facebook iPhone app.
I'm thinking that the endpoints which the iPhone accesses to retrieve data, should be the same code that the Web Application uses to retrieve data. Or with different platforms running, is it common practice to maintain completely separate code bases?
To be clear, my iPhone App would be a native iPhone app.
thoughts?
you can create a webservice for that,you can use json or xml to create webservice response format.
you can use that webservice with any platform. by parsing json or xml you can get your data and display it according to your platform specific design.

Migrating PHP web app to iOS

So I've built a web app in PHP that relies heavily on a MySQL database. Now (for user convenience purposes) I'm trying to create the exact same app, just as an iPhone app. Granted, I have no knowledge of Objective-C (just starting to learn it), I wanted to know how to go about this. I know that I'll have to use some kind of intermediary to get Objective-C to connect to the SQL database.
So essentially my questions are: If I've already created the web app as aforementioned, could I use the same DB and tables for the iOS app version as I did for the PHP web version? Also, is there anyway to migrate any code I've created in PHP to iOS (I realize that they are two completely different languages), but I'm just curious as to whether or not I'll have to build the iOS app from 'complete' scratch.
Your best bet is to write an PHP service to talk to your database.
This way you can share this API between your app or iOS app or any other type of client app.
The service will be responsible to receive request query the database and send responses in JSON format for example.
So to make things easier, you should not query the database directly from your apps, use a common web service.
You can use your MySQL database for any purpose because it is just data. The code that will show them will be different though. If you have no knowledge about Objective-C you should consider the web-app approach.
Here are a few helper links.
https://developer.apple.com/library/safari/referencelibrary/gettingstarted/gs_iphonewebapp/_index.html
http://gigaom.com/2010/02/12/how-to-create-an-iphone-web-app/

iOS/Android application with server API's to pass information

I'm working on project for iOS/ Android application that allow user to Register/Login and than create/share and store files to the server and share it with other users.
To meet this purpose i been following this tutorial: http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app but i found its very basic and i need more information before i start working on it.
My question is, how to create an application for example like Path: https://path.com or instagram, that allow apps to sync with server using API's and pass data between server, phone and users without offering Website to users?
Is there any pre-built open source php/mysql API's that we can use for this purpose?
Any brief tutorial that explain steps to do this (since until now i use to work on basic iOS app and need not require any interaction to server and stuff)?
In project im using php/mysql, in my research i found people also advice to use AFnetworking (http://afnetworking.com/) to replace stranded url fetching, any opinion on that?
I'm hoping to have great discussion on this question since there is lot of questions out there on this topic but non have full descriptive answers!
you can create our own server using tomcat and get the path that act as url for you..and there are many third party framework available for parsing or in iphone they have there own using NSJSONSerialization.you can read the detail from this link.
http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html

Create mobile application (iOS, Android, WP)

If got a task to create a mobile application for iOS, Android and WP. This application needs to access a mySQL database which is already in use by the website running php.
What I found in the meantime, is that I have to create a php webservice and use this webservice to access the data in the mySQL database.
Since I did not found any clear advice which way is the best to do it (JSON, XML, REST, etc) - I just wanted to ask you, is there a kind of best practice which technologies should be used for the php webservice?
Additional it would be great for me if someone knows a good tutorial for the recommended technology.
Thanks a lot.
I am arriving a bit late but here is my answer : I believe that the easier way currently available is a PhoneGap application (with Sencha Touch or jQuery Mobile as a javascript framework) talking to the server through a simple PHP webservice. PhoneGap allows you to build an Android, iOS and WP app with the same codebase.
We use that technology in my company and it works great.

Remote Server, php, MySQL connection within an iPhone app

I have found many places online that say in order connect to a remote MYSql database, use php. I do not know how to get from my iphone app, to php, to mysql and back. I cannot seem to find anything on the relationship of these things. I would really really appreciate any help in this matter. Where do I write the php code? Where do I call it? When do I connect to the remote server. I am new to this task.
please help
Thanks
To try and answer the question, the way this kind of access works is that you would create a web service with PHP code on a web server. This accesses the MySQL database. Your iPhone application would then make a request to your PHP web service and handle the results.
Perhaps you would find this tool of use. I'm involved in a project for allowing you to manage a hosted MySQL database, create a web service layer for it, and build a customised client library that helps you consume the results on the iPhone. The project has just gone into an open beta programme.
It's called Kumulos and it removes all the tricky, repetitive stuff associated with creating database driven apps. We're looking for beta testers and would love to hear your feedback!
You can take a look at the project here: Creating iPhone MySQL databases with Kumulos
I hope this has been of some use, thanks,
Chris

Categories