PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Oct 17, 2017 6:36 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Mar 16, 2016 12:45 am 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
Hello all,

I'm about to embark on a new project that will have be a regular website. However, it will also have a mobile website, a mobile app, and a desktop application. The mobile app and desktop applications I'm thinking will likely just contain a blank file that will grab the mobile website and display it via ajax.

Here's how I'm thinking about doing this.

Design the normal website in a place like follows:
domain.com/web (public_html/web/)

And then, the other versions will reside in respective locations:
domain.com/mobileweb (public_html/mobileweb/)
domain.com/mobileapp (public_html/mobileapp/)
domain.com/desktopapp (public_html/desktopapp/)

Basically, the full version will be in the /web/ directory. The other versions will only have files specific to those versions. For example, the mobile version will definitely have a few different templates. The main page will check if there's a mobile version of a file to serve, and if not, include the web version.

So basically I'm just doing the whole thing in /web/ and only putting files that are different in the other directories and checking for it on page load.

Is this the best way to go about this? Would another way be better? What other way? Perhaps just make an API (though, then I'd have to make 4 separate versions?). Thoughts? Ideas?

_________________
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
PostPosted: Wed Mar 16, 2016 8:40 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6571
Location: WA, USA
What are the differences between the four versions? Normally it's just in the display of particular pages, and if that's the case here then I would probably use five folders: one with the code, four with the "views" for each page. Like public_html/code/index.php serves as the code backing the homepage, does what it needs to do, and uses public_html/{desktopweb,mobileweb,desktopapp,mobileapp}/index.php for display.
Actually that suggests a sixth folder for the "framework" code. For the most part that is what runs first, it decides to invoke the code/index.php controller, then passes any data to the correct view.


Top
 Profile  
 
PostPosted: Wed Mar 16, 2016 11:50 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13434
Location: New York, NY, US
I want to know what the difference is between the regular website, mobile website, a mobile app, and a desktop application? My current practice is to implement unstyled HTML with appropriate containers for everything needed by all versions. Basic Javascript behaviors are implemented. I then apply CSS, mobile first, to create the look for each different version. Any functionality not used by a version is simply hidden. Selecting the appropriate stylesheet and adaptive behaviors are all done in the browser, so the server side code just delivers HTML and JSON.

What you are doing sounds very complicated -- unless your various versions are completely different.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Thu Mar 17, 2016 12:36 am 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
Sorry for being unclear.

The difference will be the layout and a little bit of code here and there. I will have different layouts for the Web and mobile versions (the apps will likely use the mobile layout). So, the layout template file will likely be unique. And then, for example, push notifications for desktop and mobile app will need to be coded. The mobile push code would go in the mobile app folder and no where else.

Most pages will be identical. So say there is a profile.php. On the mobile site once the mobile layout is loaded, my code will just grab profile.php from the normal website (/web directory).

But say i wanted the mobile version of profile.php to be very different with different info.. Id make a new profile.php and place it in the mobile web directory.

In pseudo code, each directory's index.php (router) would include pages like this..

If (page exists in this folder)
Include this specific version
Else
Include page from normal /web

This way i could easily just drop in a specific page for, let's say, the mobile Web version. Everything else would remain the same.

As far as mobile app and desktop app, I'm going to use phonegap (or something similar) and node webkit (or something similar). These allow for the apps to just be html/css/Javascript normal Web pages). Initially I'd just do an Ajax get request to display the initial page. Then on page change or form post id get just the content and insect it into the dom. The only actual code in the apps index.html wild be an Ajax get request.

I was thinking of using sub domains instead of folders. That way each version could have its own document root. But I'm really not familiar with this. Good idea?

Thanks for the input both of you. It seems pretty simple but i don't want to code the whole thing for it not to work without significant recoding. I'm sorry if i haven't been clear. Perhaps in a little bit I'll post a sample directory structure and index route script.

_________________
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
PostPosted: Thu Mar 17, 2016 12:54 am 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
OK, here's what I'm thinking.

Pseudo directory structure:

Code:
/framework_code/
   /psuedodirstructurehere/
   /pages/
      profile.php
      main.php
      anotherone.php
   /template/
      layout.tpl
/public_html/
   /web/
      index.php
   /mobileweb/
      /template/
         layout.tpl
      index.php
      profile.php
   /mobileapp/
      index.php
   /desktopapp/
      index.php



Then, for example:

/web index.php router pseudo code
Syntax: [ Download ] [ Hide ]
//request for profile.php, easy direct get
include '../../framework_code/template/layout.tpl';
include '../../framework_code/pages/profile.php';
inject content from profile.php into layout.tpl
display page


/mobileweb index.php router pseudo code
Syntax: [ Download ] [ Hide ]
//request for profile.php, which has a mobile specific version
if (specific template file in this folder)
        include template/layout.tpl
else
        include ../../framework_code/template/layout.tpl

if (profile.php is in /mobileweb folder)
        include profile.php
else
        include ../../framework_code/pages/profile.php
inject content from profile.php into whatever template was grabbed
display page


This would allow me to basically make only the main web version, and anything specific for any other version can just dynamically be dropped into the corresponding folder. Typing it out like this makes it a lot clearer for me, so that helps. Should've done this first, I guess.

With subdomains, such as:

web.domain.com
mobile.domain.com
mobileapp.domain.com
desktopapp.domain.com

Each folder would be it's own document root. I think I'd be fine with doing the above even though the includes will technically come from another subdomain, right? (include ../../framework/etc.php from mobile.domain.com would still work?)

I could set the cookies to work on any of the subdomains.

Sorry for long post.

EDIT| 5000 posts!
EDIT2| Actually, in the framework code templates folder, I should split that up into subdirectories for each versions templates. That way, I can check the versions folder, include that template if it exists, otherwise include the main web template for that page. This will stop me from polluting the public directory with templates.

_________________
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
PostPosted: Thu Dec 15, 2016 4:54 pm 
Offline
DevNet Resident
User avatar

Joined: Wed Sep 25, 2002 7:47 pm
Posts: 1708
* ReactJS for UI
* NodeJS for Server
* PHP as the API


Concerns nicely separated, code becomes loosely coupled.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group