Link to home
Start Free TrialLog in
Avatar of Ruwenzori Warrior
Ruwenzori Warrior

asked on

Progressive Web App using Apache and PHP

I am using a PHP based framework for a web app called Yii, its MVC. I am planning to create a Progressive Web App. 


The technology that the PWAs work on, are all client side technologies e.g. node.js, service worker libraries and Javascript.

I searched the internet if I can use Apache and PHP to create a PWA, there were some articles about using Apache server as a reverse proxy and getting a connection from the node.js server.


I have not found anything concrete on this, wanted to ask, is it possible to create a PWA using Apache and PHP? I am not finding lots of resources, apart from the hacks that I mentioned above.


Thanks

Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

for the backend yes. for the pwa NO as it runs in the browser
As @David Johnson mentioned, whatever backend server you use Apache, NGINX, NodeJS have no real bearing on a PWA, as most of the PWA type code will likely be written in Javascript + AJAX.

Tip: If you've ever wrestled with getting NodeJS to work, then try tuning it for high performance, you'll likely return quickly to using PHP as Opcache PHP optimization is very difficult to approximate through any other language.

Before you start writing lots of code, write skeleton code for proof of concept for your code, then stress test it thoroughly before committing to a specific Code Stack (layers of code you'll use).
Hi,

I would recommend to create a native apps using React Native.
The great thing is that you code once and can create IOS and Android version.
Ref https://reactnative.dev/

React Native for Yii dev (this may be useful)
https://github.com/ziaadini/react-native-for-yii-developers



I have only done this from Wordpress using https://wordpress.org/plugins/pwa/ and it was super easy.  

The idea of the PWA is it is going to work offline when there is no internet connection. That means static pages. https://web.dev/progressive-web-apps/

The web.dev site has a lot of good information, but these two may make it easier to digest
https://www.freecodecamp.org/news/build-a-pwa-from-scratch-with-html-css-and-javascript/
https://dev.to/developertharun/convert-any-website-into-a-pwa-in-just-3-simple-steps-35pp

wanted to ask, is it possible to create a PWA using Apache and PHP?
A PWA is the front end, HTML, CSS and JS.  Your Apache/PHP/MySQL site can produce the front end HTML mark up that gets pushed to the browser. so in a sense, yes, you would use your php to help generate your HTML,CSS and JS along with your static front end code.

Try playing with the test in the first article I posted for yourself and that may help get a better understanding of what this is. Then transfer what you learned to your own site.

What is your ultimate goal? Are you trying to make an offline version of your site? or are you trying to make an easy option for a native application? What functionality are you expecting from this? Something dynamic where people are interacting? or just being able to view content like articles?
Avatar of Ruwenzori Warrior
Ruwenzori Warrior

ASKER

Scott Fell, thank your for your resources, I will play around with them.

What is your ultimate goal? Are you trying to make an offline version of your site? or are you trying to make an easy option for a native application? What functionality are you expecting from this? Something dynamic where people are interacting? or just being able to view content like articles?

My ultimate goal is to create a site where users can sign up for push notifications to a pick up game that will happen every week. The game might be held in different locations, so push notifications can save lots of headache in terms of finding the pick-up games. Eventually, the notifications will be used to determine how many players are going to show up, so a small for with buttons. I have plans to blow this into a long running personal project, called SportsBuddy, but for now testing the waters with different technologies.
I see.  These types of push notifications are based on the browser though. Do you think that could cause an issue because people tend to block these?  You would have to make sure they allow the push notifications.

https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Re-engageable_Notifications_Push

What people may be more apt to receive are text messages along with push.  Have you ever looked into an API like Twilio?

With Twilio, you can have your back end send out notifications from as a text message from a phone number you choose. Phone numbers are $1 per month and messaging is $0.0075. For a small group, this is not very expensive at all, yet very effective. Plus, people can reply to the sms where you can forward the message or save it to a database and do what you need. For example, "reply 'yes' if you can make it. When the 'yes' comes in, we know the phone number it was sent from, therefor we know the person. We can set  up a listener and mark that person as a yes or no. There is a lot of potential.  There are now competitors to Twilio, but not only were they the first out with this type of thing, they have an excellently documented API.  

Also, if you send a push, it will be more like it was coming from a native app rather than via a browser push.

If you have 500 people in your group and you send out 500 messages a week and get 500 messages back to you a week, that would cost you less than $9 per month.

https://www.twilio.com/sms
https://www.twilio.com/notify/api


Scott Fell,

You make a very good point, one that I thought about before going this route. I want the user to be able to refuse push notifications from the app.

I currently belong to a group that arranges pick-up soccer games, locally, here in Fresno. The group democratically elects a three member panel, which make decisions on rules for the games, and since I joined, I.T. as well. I want to use this group of 30 people as my test subjects for the app, the panel unanimously agreed that they would not be comfortable with the phone numbers of the members in the database. The only option after that was push notifications. The notifications will ask them to check-in for games on Tuesdays, also, if there is a change in scheduling it will update the new location.

Twilio sounds like something I would definitely use at a later time.

I am using the results from my testing from this app as the basis for my long term project.
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

What you can do is to create a Facebook page (public or private) and inform the players from there.
This is very easy to set for you and it is easy for the user to change the notification from FB page.
And if they access FB from their mobile device they will received the FB push notification.

 


@Scott Fell
you are absolutely correct, I will have a chat with them and I hope they will allow me to use the numbers of the current members. Yeah, you got it, all I want is some sort of push notification where the player can get information and sometimes relay back some information to the server, that was my main aim for looking into PWAs, also, with PWAs (correct me if I am wrong) there is no need for logging into the app for receiving the push notification, so that is something that i am after, I am going to assume my users do not want to create a new set of creds for a site. Thank you for your link, I will check it out.

@lenamtl
That would be awesome, actually an ideal solution, but, I want to lay some groundwork for my long term project and therefore need to use solutions that do not involve third party platforms. Also, want to use the feedback to better optimize the texts (visually).
Hi,

If you want to use Native mobile features, you don't have the choice to create a native apps.
So in order to use the native push notification you will need to create a native apps.

This is not possible to send Native push notification using PWA.

If you are thinking long term without using any third service then use React Native or any native language to create a native apps. This way you will be able to set what you need and user will be able to manage the notifications.

React Native is not very complicated, the learning curve is more about to setup the web server.
The ability to create an apps for both Mobile OS is a big plus as you code once for the both OS.
And you will be able to use all native features.

I would use the Facebook solution for now this allow you to start quickly, this will give you the time to develop a react native apps (or other native language) when everything is ready, user will be able to use the apps or use FB, I would continue to use FB too so it reach more users as not everyone will install the apps, but at this point you will see what works for you.