php - How to efficiently make a game for web and mobile with Laravel -


years ago started making own browsergame, in raw php bit of javascript. it. times has changed , since initial release of game years ago, mobile development became more , more important. want translate game raw, self-written php more stable version, , want make available mobile native app. there 2 important things want change game:

  • i'm transforming game raw php laravel 5 framework. way don't need write code authentication , on myself more. want implement socket.io realtime data (and i'm thinking angularjs single page experience, i'm not sure yet).
  • and, want create mobile experience: game should playable on mobile devices. started using unity3d it.

both versions (web , mobile) should call api handles crud , safety checks. there have problem: want save myself work want write few possible duplicate code web- , mobile version. want webfront-end , unity game communicate same api.

let's have example: have http://api.example.com/?check=login&... checks if right user credentials given. think way make api lumen (the laravel child). well, know how send request unity api. how do within laravel webversion? mean, laravel web version should connect api, otherwise have rewrite logincheck both web , mobile instead of 1 central place. or there better option? i'm bit tired of information , possible things hope can make more clear :)

so, summarize question , make not broad:

  • 1) i'm newbie in developing web , mobile: thinking right way?
  • 2) if it's possible: best way interact 1 code base (/api) both web- , mobile version? should use seperate api.example.com domain handles everything. or can mobile game communicatie normal laravel application?

i hope can me, or please let me know if unclear.

you can have same api web , mobile versions , use json web tokens authentication - way don't have manage user state via cookies , other browser-locked mechanisms make difficult reconcile between mobile platform , web.

so game , browser can communicate laravel app on api if go jwt route.

there's dingo can use api, , a nice jwt wrapper laravel uses dingo. i've used in production reactjs in spa great effect.

hard answer without knowing yo trying achieve, , specifics of game - hope helps!


Comments