Migrating from a free web host that uses mysql and phpmyadmin to Coronium

Hey guys,

I’ve been developing an app for some time now, and I began by using, like the title say, a free web hosting site to store my database and php scripts. So far, my app only does account creation and verification. I am in the process of migrating to coronium, but I am a little stuck and not sure where to begin (I already have my instance of coronium set up and running with AWS EC2).

If anyone has gone through this process before, what would you recommend? Re write the server side from scratch to work with coronium, or simply try to change little things from the php scripts to work with a new database?

Any help is appreciated.

edit: Where do i create my database?

bump

Depends how much of the original backend you’ve done, I personally would move over from mysql and php and use lua backend scripts, if you are using corona you are already writing in Lua so it shouldn’t take too much.

I have an app that I did for a client and I used his server and wrote all the PHP scripts and used mysql, it was a pain in the butt but rewarding in a weird way. Coronium is a lot easier to use and unless you need stuff like geolocation (which I do) then the basic stuff seems to be all covered, moving to mongodb from mysql I also found a lot nicer and easier, I’m also sure version 2 of coronium will be even better. 

I dont think i would mind at all to move to lua backend scripts, I just honestly don’t know where to begin… My original backend was only a database and some php scripts to handle user creation and login, the usual stuff. My app also happens to need geolocation, actually one of its main functionalities. Since you’ve been through the process before, I would really like to have a chat with you, maybe through the messaging system provided here on the forums, as long as you are willing to provide some assistance, of course.

Hi,

Not to have you lose a bunch of work, but you might start fresh using the User module in Coronium.

The other issue that could pop up is PHP compatibility. The PHP module is only meant to handle simple use cases. If your PHP has dependencies or is framework based, you won’t be able to use it in the system.

http://docs.coronium.io/en/latest/

Cheers.

I don’t mean to sound ignorant, but, what would this mean for my database? Would i no longer require a database with coronium to store users and their information (including location)? I just really am lost, if i were to start fresh (which i dont mind), where would I start? Are there any sample apps that use coronium as back end? I tried searching all over but i simply couldnt find any that could help guide me through this process.

Thanks!

Hi,

There are no ignorant questions.  :wink:

Coronium Server is an all-in-one stack. It includes the database(s), simple analytics, Cloud Lua, email sender, Push integration (via external service), User management, etc.

Out of curiosity, are you currently communicating with your backend with a test Corona application?

There is no doubt that you would need to spend some time with the docs, as Coronium is a fairly simple to use, yet deep tool-kit

Just to throw out an (abridged) example:

[lua]

–Corona SDK, on the device.

local coronium = require(‘mod_coronium’)

coronium:init( …see docs… )

coronium:addUser({email=“me@here.com”, password=“1234”, fav_color="Blue})

[/lua]

Now you can use other User module methods.

If you just want to store some data:

[lua]coronium:createObject(“Pets”, { name=“FiFi”, color=“Maroon” } )[/lua]

These calls also return “object” ids, which can be used to call them back, or you can query a datastore as well.

[lua]coronium:getObject(“Pets”, “object-id”)[/lua]

or

[lua]coronium:getObjects(“Pets”, { name=“FiFi” } )[/lua]

This is using Mongo DB as a backend. If you want to use MySQL, you need to create Cloud code (for security). The Server side API is slightly different in how it works, but in general, an SQL query looks like:

[lua]

–This is Cloud Code, on the server.

–Create query

local q = “SELECT * FROM ‘Cars’”

–Run query

local answer = coronium.mysql.query( {database=“mydb”}, q )

[/lua]

You will receive your results in a Lua table format.

All of this doesn’t really matter though if you need GeoLocation queries. It’s something that I have put many hours into solving, but have yet to find a proper conversion for deep table arrays from Lua to the BSON that Mongo wants. I haven’t given up on it though.

Hope some of this helps. Coronium should be considered another “tool” you need to learn and spend time with to really understand it.

You can’t really break anything (that can’t be re-installed) so I would recommend some experimentation time.

Cheers,

Chris

Chris, since I sent @yanko_l10 to Coronium and I’m not sure of the server side scripting abilities,  can he write a server side script to query all people whose latitude is > some value and < some value and whose longitude is > some value and less than some value and then return that list of users to him?

His geolocation needs don’t seem to be that complex. He know’s where his user is and what distance away people need to be, so he can calculate a bounding box and fetch people in side of that.

Rob

Hi,

Yes, I was thinking of suggesting something like that as well. All that is needed is to store the coordinates on the User object:

[lua]

coronium:createUser({email=“me@here.com”,password=“1234”, lng = 36.0, lat = -57.0})

[/lua]

You can use any of the Mongo “operators” in a query (except geo-related due to Lua array handling).

I’ll write up a little sample query in a bit.

Cheers.

Hey guys,

To start off, I would like to thank you for replying, your posts have clarified a lot for me! @develephant, I’m not sure what you mean by corona test application, if you mean the sample applications that come with the sdk, then no, I’m working on a personal project (started from scratch). I feel silly now, because what was causing me the most confusion was the fact that I had no idea where to create my relational database… I actually had already gone through everything (I think) in the coronium docs before. I now found the database tabs in the coronium instance, either the MySQL one or MongoDB. I noticed from the code you posted of the User module, it’s not pointing to any specific database? Also, you mention that to use MySQL we need to use cloud code to query the database, does this mean we cannot use php scripts? (I know that’s stupid to ask, considering there is a php directory in the instance, but just making sure)

That being said, is there any benefits/disadvantages of using one or the other (MySQL vs MongoDB)? Or is there one that is recommended to use when working with coronium? I know this probably boils down to personal preference, but I just want to know, just in case, so I wouldn’t find myself in the future having to rewrite everything once more.

Adding on to what @Rob Miracle (thanks for filling in for me! I was in class all day) said, from what you explained, can I assume It’s also possible for users (in my app) to set up a meet up location amongst them?

Thanks!

Hi,

The idea behind Coronium was to abstract away as much of the “busy” work into the core API. So, for instance, the User module uses MongoDB, but it already has a prepared database (including sessions, etc), so you just use the API calls, and the datastore manipulation is handled behind the scenes. Data Objects are stored in Mongo as well in their own namespace. You don’t “create” anything.

As far as MySQL, it’s provided mostly due to its popularity. PHP as well, is a “bridging” function and not really meant to be used as the core of your Coronium app. You will have to experiment to see what works, and what won’t in PHP land.

I have to ask, but what is keeping you from using your current setup? Do you have a particular need to use Coronium? It sounds like you already have most of your functionality handled. Wouldn’t it be easier to move to a host like DigitalOcean and use a prebuilt LAMP instance or something? I’m not trying to deter you from Coronium (I’d love for you to adopt it!), but I also think that any developer should work with the tools that they are most comfortable with. No need to bring in extra complication if you already have a working base.

Coronium tends to be easier to adopt if you have little or no previous server/database knowledge. Actually knowing how to work with the PHP/MySQL combo will most likely leave you scratching your head, because what you are used to dealing with has been abstracted away as much as possible in Coronium. As far as development is concerned, the preference is LuaJit/MongoDB over PHP/MySQL.

Hope some of that helps. 

Cheers.

Hey @develephant,

To be completely honest with you, I’m not really sure. it all started off with me finding this tutorial while doing some searches in google, which consisted of using Parse server to make a simple chat application using corona. So looking at the tutorial, it all just seemed really simple, and it made me think that there was a RIGHT way of doing mobile apps, using the RIGHT backend. So that lead to me asking on a different topic about picking a backend/backend service, to which @Rob Miracle recommended using coronium.

The other kind of big reason why I thought I would need something like coronium was because of the functionality i wanted to implement to my app: Giving the users ability to set up meetings amongst themselves, so user-to-user interaction, which from what I understood, required push notifications, something that I thought only services like coronium could do. A bit after that, Rob again clarified that php can actually handle push notifications.

I’m actually fairly well versed with mysql, but a little less with php (took database management last semester), enough to handle or be able to figure out what I need.

So to sum it up, I really don’t know anymore if I should stick to coronium now, from what you just told me. I guess as long as I figure out how to handle push notifications from a normal amp server i wouldn’t have to switch over (finish switching over).

I appreciate your honesty though!

Hi,

There is no doubt that a PHP/MySQL combo can handle everything you need. I spent years in that space as well. Coronium was an opportunity to explore some other technologies, and simplify some of the whole “stack” work for others who would rather not get too involved in the ops side, but still maintain control of their content/data.

In either case, good luck with your app adventures. :slight_smile:

Cheers. 

bump

Depends how much of the original backend you’ve done, I personally would move over from mysql and php and use lua backend scripts, if you are using corona you are already writing in Lua so it shouldn’t take too much.

I have an app that I did for a client and I used his server and wrote all the PHP scripts and used mysql, it was a pain in the butt but rewarding in a weird way. Coronium is a lot easier to use and unless you need stuff like geolocation (which I do) then the basic stuff seems to be all covered, moving to mongodb from mysql I also found a lot nicer and easier, I’m also sure version 2 of coronium will be even better. 

I dont think i would mind at all to move to lua backend scripts, I just honestly don’t know where to begin… My original backend was only a database and some php scripts to handle user creation and login, the usual stuff. My app also happens to need geolocation, actually one of its main functionalities. Since you’ve been through the process before, I would really like to have a chat with you, maybe through the messaging system provided here on the forums, as long as you are willing to provide some assistance, of course.

Hi,

Not to have you lose a bunch of work, but you might start fresh using the User module in Coronium.

The other issue that could pop up is PHP compatibility. The PHP module is only meant to handle simple use cases. If your PHP has dependencies or is framework based, you won’t be able to use it in the system.

http://docs.coronium.io/en/latest/

Cheers.

I don’t mean to sound ignorant, but, what would this mean for my database? Would i no longer require a database with coronium to store users and their information (including location)? I just really am lost, if i were to start fresh (which i dont mind), where would I start? Are there any sample apps that use coronium as back end? I tried searching all over but i simply couldnt find any that could help guide me through this process.

Thanks!

Hi,

There are no ignorant questions.  :wink:

Coronium Server is an all-in-one stack. It includes the database(s), simple analytics, Cloud Lua, email sender, Push integration (via external service), User management, etc.

Out of curiosity, are you currently communicating with your backend with a test Corona application?

There is no doubt that you would need to spend some time with the docs, as Coronium is a fairly simple to use, yet deep tool-kit

Just to throw out an (abridged) example:

[lua]

–Corona SDK, on the device.

local coronium = require(‘mod_coronium’)

coronium:init( …see docs… )

coronium:addUser({email=“me@here.com”, password=“1234”, fav_color="Blue})

[/lua]

Now you can use other User module methods.

If you just want to store some data:

[lua]coronium:createObject(“Pets”, { name=“FiFi”, color=“Maroon” } )[/lua]

These calls also return “object” ids, which can be used to call them back, or you can query a datastore as well.

[lua]coronium:getObject(“Pets”, “object-id”)[/lua]

or

[lua]coronium:getObjects(“Pets”, { name=“FiFi” } )[/lua]

This is using Mongo DB as a backend. If you want to use MySQL, you need to create Cloud code (for security). The Server side API is slightly different in how it works, but in general, an SQL query looks like:

[lua]

–This is Cloud Code, on the server.

–Create query

local q = “SELECT * FROM ‘Cars’”

–Run query

local answer = coronium.mysql.query( {database=“mydb”}, q )

[/lua]

You will receive your results in a Lua table format.

All of this doesn’t really matter though if you need GeoLocation queries. It’s something that I have put many hours into solving, but have yet to find a proper conversion for deep table arrays from Lua to the BSON that Mongo wants. I haven’t given up on it though.

Hope some of this helps. Coronium should be considered another “tool” you need to learn and spend time with to really understand it.

You can’t really break anything (that can’t be re-installed) so I would recommend some experimentation time.

Cheers,

Chris

Chris, since I sent @yanko_l10 to Coronium and I’m not sure of the server side scripting abilities,  can he write a server side script to query all people whose latitude is > some value and < some value and whose longitude is > some value and less than some value and then return that list of users to him?

His geolocation needs don’t seem to be that complex. He know’s where his user is and what distance away people need to be, so he can calculate a bounding box and fetch people in side of that.

Rob