NativePHP for iOS with Simon Hamp - podcast episode cover

NativePHP for iOS with Simon Hamp

Feb 13, 202531 minEp. 21
--:--
--:--
Download Metacast podcast app
Listen to this episode in Metacast mobile app
Don't just listen to podcasts. Learn from them with transcripts, summaries, and chapters for every episode. Skim, search, and bookmark insights. Learn more

Episode description

Simon Hamp discusses the development of Native PHP iOS, a project that allows PHP applications to run natively on iOS devices without needing a web server. He shares the journey from the initial concept of Native PHP to the realization of mobile app development, the technical workings of the application, potential use cases, and future enhancements. The discussion highlights the empowerment of developers familiar with Laravel to create mobile applications and the importance of building a cohesive ecosystem between server and mobile applications.

Show Links: 

Transcript

So Simon Hamp is back on the show last time he was here. We talked about native PHP this time He's got a brand new thing native PHP iOS. So welcome back Simon. Thanks for having me Eric It's so good to be back. It's good to see you again. Yeah, you too. So I Think at first we thought native PHP was crazy and you're just like no that's not crazy enough So we're just gonna go full bore into mobile development. So so how did this come about?

Where do I begin? Well, I mean obviously it starts with native PHP because none of this would have happened without that but Basically last year I was looking into I was looking into doing something that probably I shouldn't have Shouldn't do which is like how can I run?

PHP without a web server behind it and the reason for that was kind of like I'm looking into building all of this stuff for native PHP for the desktop stuff and And doing it without web servers and then it kind of dawned on me I was like, you know, I think this is gonna work on a phone because Now we haven't got to run a web server. It's so I started investigating all of that and I'm like, oh actually I can't run Like PHP as an a separate executable on

the phone. So I start to investigate like how do I do this as a embeddable PHP and And all these pieces just start to fall into place and then I'm like, do you know what?

I think I'm gonna just hold here for a bit And I'll just seed a few people with the idea of like, maybe we can do this You know talk to Marcel about it I was like, I think we can do this and we were at Laricon US and I mentioned it to a few people There's some people in the community who have been on at me like when is it gonna be ready for mobile? And I'm like, oh And I said to them I think I've cracked it, you know, like I think we're we're nearly there and

Coming back from Laricon US. I was like Well the the Laricon EU Call for papers, you know call for talks opened up and I was like, all right I'll just put a talk in like the really Smallest brief that I could write for a talk was like building mobile apps with PHP and then like months later

I have completely forgot about it. I was just like, okay, I'm not gonna do anything I'm gonna wait till I hear if I get anything back on this talk and if they say no, that's fine But to my surprise Kaneko came back to me like out of the blue a couple of months ago He was just like really like your talk idea Do you still want to give

it and I was like hell? Yes I want to give it but I haven't built any of the stuff that I said that was gonna build So now I've got to go and figure that out so I finally kind of knuckled down over like the holiday period and just Smashed out this thing and I was like couldn't believe that it actually worked And yeah, then I started sharing more and more stuff about it just like leading up to my talk so that's kind of how it came to life, it's probably been a year in the making and

Quite a lot of work to get there. But Got the so yes you so basically he by accepting the talk you had a deadline So at that yeah, it's had to get something done, right?

Can echo got his whip out and started Giddy up that's funny, so As far as like the back end on on how this actually works So you write in PHP you can use a lot of wire of course I guess CSS normal CSS like tailwind or something and then it compiles itself into an Xcode thing or I guess I don't know how that works like what what actually runs on iOS So it's an Xcode project that gets kind of bundled together But your your Laravel app gets kind of injected into the Xcode

project and then I'm not like transpiling any PHP code into Swift or any other language. It's still

running as PHP code. So Your actual Laravel project goes on to the phone and it runs as PHP would on the server kind of but on the phone so it's what's happening is the PHP engine has kind of been embedded into the app and so when the app sees like you're asking it to Basically kind of make a request to PHP, you know, which Laravel does very very by default It kind of boots up the PHP engine runs the whole Laravel application through the engine as it normally would and then just gets the

HTML and the headers back and kind of injects all of that response into a web view and it does it without Without the web server I'm saying earlier. So there's no there's no Processes that are sort of hanging around on the device trying waiting for

requests. It literally just goes Oh, there's a you want this I'll spin all of that up and then finish that and then here you go which is Good, you know like for me that's cool because now I can take all my Laravel stuff and I can just do it on the phone But yeah, this it's not native in the sense of You know building a like native UI components yet, but it could get there Yeah what about I know you said it's sort of like bundles sort of a version of PHP.

What about like a database like What's your idea there is is it gonna be able to like?

Use whatever the iPhone storage is or you're just like doing more like API calls back to some other thing You you've got kind of choices there I think when when people think about Laravel they think I can connect to my sequel or Postgres or all these other drivers and But you have to kind of get into the mindset of I'm building a client application You know, my Laravel app is really a client to something else potentially I mean, it could be just completely standalone

But if you're thinking, you know, I want to run Postgres somewhere Let's say like you've got a service running on Laravel cloud And you've got a Postgres database you Absolutely do not want to be connecting your client applications Which could be installed on hundreds or thousands of phones in theory all to that one database without any kind of intermediary so you'd want it to be going through an API that you've got authentication going on and you can Tell who's doing what and you know?

give out tokens that you can expire and all of those kinds of things and just have like a good level of control that the Database server just won't give you by default without, you know a lot of work So in that scenario, you should pretty much always be thinking like it's going through an API But because it is just a file system On the phone you can have a like a sequel light database running on there and it comes with sequel light support so, you know, and Laravel's done a lot of

work in the last couple of years to Make sequel light support like a real first-class supported solution, so It's actually great for that now and it works really really well. So you can have a local database that you're Updating with like eloquent models and you know using migrations and stuff on the device Which just feels like you're right at home in Classic Laravel world, which is great

That's sweet. Uh, what about so What is like the best use case You know Sort of this is sort of my thinking the way you're kind of describing it Like it's never gonna be like you can never like build little games or something with it But it's more like B2B apps things like that or is it? Hmm Yeah, what's your thoughts there the first app that is you know The app that I built that went through the App Store that Apple have approved

Is a game technically. I mean, it's not like three-dimensional stuff but There's actually a project called PHP GL Something PHP GLFW or something like that and it's like They're trying to make open GL drivers in PHP and all of this so I can kind of see a point in the future where that could be possible because there's nothing really preventing you from connecting to the the hardware and running all of that kind of I mean, it's just More maths really, you know, like more

calculations that happening But should you do that in PHP I don't know I Think people will definitely go we're trying to build a really performant game here Let's use like the proper frameworks that are available on the platforms whatever but yeah Business apps. I mean I can see like potentially businesses that have they've already got like their service like a sass And then they want this kind of side car Application that's installable on the phones So, you know, they might not ever

Sell that app through the store. They might not ever do anything that kind of directly generates revenue from that app But you know, it's a feature of their entire platform And then you know You could get going basically if you had a team of like one or two Laravel developers And he didn't want to invest in hiring like Swift developers and Kotlin developers or react native developers You got a team now that can build a native app still with their Existing Laravel skills, which I think is

super powerful and and cool But I do think another thing is like people just have these ideas, you know They I've talked to friends over the last few weeks and they're like I've had this idea for an app and it's like Yeah, but you know You don't really know how to code and you don't know how you're gonna have to learn all these languages and tools and things and it's like I can't build it for them because I didn't know Swift and I didn't know these other languages

But now I can because I already know like Laravel and PHP so I can just go Oh, actually, let me just you know and a day later. It's like here's your app That's quite cool. I think that's gonna be Empowering people to kind of try new stuff out and bring new

ideas to life. Hopefully Yes, I think that'll be great I was you know, I was just thinking my own use case like it'd be sweet just to have a little little news app OS app, I don't know who would download it But you know it would be neat to have that as an option at some point, you know

Or a golf app. It's like no, you've probably got loads of good golf apps You know, I don't know It would be cooler to to hook into we've actually made another buddy talked about this before It's like have an iOS app where we can like video your swing and then we hook into like Chat GPT or one of the AI stuff and it's like this is what you're doing wrong You should probably work on you know Here's some training aids and something like that might be kind of cool and you could probably do that

through something like this Because it would just be connecting through API's Yeah, I guess because I did see you take a picture on on stage So it's definitely possible to hook into

the camera, right? Uh-huh I mean videos are different beasts but I think what you know what you're talking about is essentially like you capture a bit of video and then you want your app to take that file and Automatically sort of process it through some other API and get some data back, you know, it's like Yeah, you could like that's just very basic web API Interaction stuff so you could totally do that with Laravel now and that's very very cool Potential stuff that

could come from this. Yeah Yeah, I agree and well even you know, talking about more sale and beyond code, you know having a tinker well on your phone that That could be kind of interesting. I don't know what you do with it, but you could play around with PHP You know as you're as you're doing something Yeah, or or more of like an iPad app or

something. I don't know but but yeah, that's that's very cool So, so what do you think I know right now you're iOS only but you do have it that you're trying to get the Android Anything else like big that you're wanting to get done before

before the first release. I Mean, there's loads of API is that I want to you know, I'm working on getting working so that they're usable and One of the things I didn't get to do before my talk which I hoped I'd have time But didn't was to kind of wrap it all up in the nice We've got quite a nice API now for native PHP for the desktop stuff and like the packages are kind of stable and all of that So I want to bring some of that stability across to this kind of straight away

so we get all of that for free in some respects and You know, it'll be nice then to have this you'll have like ID support and all of the IntelliSense things are gonna be nice and working Yeah, I mean I showed off some of the camera stuff but there's a bit of work to do to make that really smooth and get video And all of those things going but I think some of those things definitely But there's a couple of things that come to the top of the list for people always push notifications is one

because people basically people want to be able to Make the the thing kind of remotely sensitive to the stuff that's happening in their application Environment elsewhere which makes perfect sense

And another one is in-app purchases. I I haven't ever looked into stuff like that before but I think it would be really cool if you could have a Laravel app that somebody can go into and they can just trigger like the you know Apple pay to purchase something and and that flow just does what it does and then I don't know Maybe it unlocks something in your app or maybe it's like taking an order for fast food restaurant who knows but Kind of the fact that that then could be done in Laravel is just

super cool and opens the door to You know people businesses generating revenue off of this thing, which is

awesome. So I'd really like to get that done But yeah, there's just so much more there's loads and loads of stuff that I want to do this is so cool So so that that does sort of bring another question in as far as like when you're developing locally You can since it's PHP You can just run like PHP unit pass Sort of the whole normal testing suite or you have to like get fancier with how you're gonna test all this stuff No, so obviously when you're talking about like potentially hitting native APIs

They're not going to be available if you're just running your test suite in the terminal because you're not running on the device you're not testing on a real device, but We already have that again in native PHP for desktop where You might not be running all of your tests inside the browser and you know kind of the web view environment of electron and so we we basically have a whole bunch of mocks and you know fakes that can

Swap in at test time. So yeah, it's not it's not going to be testing the real stuff But it's not going to prevent you from having really reasonable tests against those Apis and kind of what your expectations are going to be That's coming through really well and a lot of that's been thanks to contributors, you know Giving of their time and making that stuff because I haven't had the time to do that So, you know I think at least to that side of things the communities really come forward and

kind of helped make all of that possible and I Think we can take a lot of the principles of that and bring it over to the iOS

stuff as well. Definitely. No, no doubt sweet another question is there any Sort of performance implications for using native iOS versus I guess Swift I assume there might be but yeah, is it super noticeable or is it still pretty quick and I I think it's noticeable because I'm maybe a bit more sensitive to that Basically like understanding what's going on under the hood helps here so for every request that you expect your Laravel application to kind of handle and respond to

We've got to boot PHP up completely from scratch I mean, it's not even like on a web server where you might have op cache, you know or Processes like in PHP FPM in engine X I don't get to tell you but you know, you have processes that are just there

They're ready. They're waiting to serve requests And so when a request comes into the web server it goes which one of you is free Do this thing and because it's already there and waiting it's kind of super fast in this world We can't spin up processes and have them just waiting around for the user to do some stuff So we literally have to spin PHP up right from the beginning on every single request at the moment Which you know, like there is just overhead to doing that every time

There's some things that we can do to speed that up I do think we can get up cache going at some point and I think I already started exploring some of the Putting pH 3 PHP in a thread on the device, which you know swift and and this they can all support multi-threaded applications so in theory at least it could be possible to have like the PHP Process just kind of it's not processed but the the engine just like primed and ready, you know, like kind of ticking over

Waiting for the next request and then and then it will be a lot lot faster but I will say like right now it's not

It's not too slow. It's not like you tap the button and then you're like You know waiting for something to happen It does react quite quickly But it is a bit I will say it's a bit slower than you know If you've got native UI and you've got it's just running native code directly because well you've got all this extra stuff that's happening so yeah, it probably adds like a 150 to 300 milliseconds to the whole thing which you know on occasions it can feel a little bit slow

Gotcha, yeah, it sort of reminds me of

you remember the old day. Well, you're probably not old enough to know the old days but So the old days with you know, we were we would build web apps and it was like Oh, you've got a you've got to compress all this down You know the extra 10 kilobytes is gonna dial up, you know, you would check you would have to You know toggle the the thing in your browser to simulate dial up and all that stuff It's like, you know now it's like if you know if my if even on my cell like only

just being on the browser It's like it's still quick. It's crazy how much faster everything it's just

gotten over the years. So that's So, you know hundred to three hundred milliseconds probably is not that bad For now, I should be building People who are used to building stuff on I you know, like on an iPhone that iPhone app developers will go Oh, man, this is slow, you know because they're so used to be it being instantaneous Especially when you're not making network requests, you know, we're not going out

to the network. So it should be really fast but my kind of counter to it is this is very early stage and We'll get there I think it's never going to be as fast as truly native because it just can't be there's too many layers of stuff going on In between but I think we can we can squeeze it down So that it's almost as good as and I think it's good enough right now And I think that's fine for a lot of use cases, you know I think there's a lot of a lot of businesses a lot of agencies

that will find that very very acceptable, you know, so Hopefully anyway Yeah, that makes sense.

That's perfect sense. Um, so Any features or anything that I did not ask you about that you want to make sure we get covered on this Yeah, I mean I guess one of the things that I have been thinking about and I was talking about with somebody yesterday even is The whole ecosystem of of building stuff Like mobile apps along with a server based application, you know And this kind of you're building all of these tools and you fit them all together and they're all in different things

You know, you might have react native mobile apps So you can do it cross-platform on iPhone and Android and then maybe on the server You've got Laravel and maybe some other bits and pieces But generally, you know, you're communicating with like a Laravel API and I just I've always felt I've done that for years And I've always felt it's a little bit disjointed because not only if you're gonna have these teams of different people with different skills and you've got to come up with these

mechanisms for these systems to communicate with each other and you've got to document all of that stuff and You you've got people doing diagrams and writing docs and it's going out of date and you know, all of the things I Think having Laravel on both sides of the equation Really has the potential to unlock something incredible that I don't I don't see many people talking about maybe I'm being ignorant but Where you you just forget about the API all together and these things just click

together and they just work So you can just go I install this package over here in my iPhone app And I install kind of the counter version of that for the server on the server app And now they can just talk to each other like securely like best practice safe and everything and syncing data You know between the two and you're just using eloquent on both sides And you're just like you don't even care like is it talking to the API or is it talking to the local database?

I don't know. It doesn't matter because it just works, you know It's like I've never had it that easy and I think that I meant like this far away from Doing something like that and I just that feels to me like a killer opportunity to tap into for people So like I see this is like a Foundational technology, you know getting these pieces to work But then the real stuff is when you can go these all things fit together. So that's gonna be really cool Yeah, that's gonna be it's it's gonna be

powerful. I you know the Feedback I've seen just on the native PHP original is Super positive and everybody seems to like like it outside of a couple of Community places that I'd rarely visit But all the feedback I've heard it really good Tons of potential I Like that when you said native PHP original it made me think of Pringles This is the you got desktop was like the red tube of Pringles What should the what should the mobile one be?

Sour cream and onion because it's got you got the green in the That's good, I like I was thinking maybe like the what's the spicy one or paprika or something, you know We might not have those here in America or I've not seen those it's I've seen it's the basic version of Pringles It's like playing barbecue

sour cream and salt vinegar. No You're missing out to get you need to get into European shores and try a paprika Pringles You know, it's this is Tony I'm the subject but Paul that You know does a lot of writing on the liberal news He's he's one of these chip connoisseurs and he just tries to find the wildest chips He can find it eats them and I'm like, it's like ketchup and you

know pickle ketchup. I'm like None of that In the UK there was like one of the common flavors, you know I mean you get them bolty pack flavor of crisps, you know, and it's got salt and vinegar and it's got the salt it you know and just Cheese and onion and then the one was always in there was prawn cocktail What nobody loves this it stinks That just sounds like the name itself just sounds terrible. It's like I would never want this That's hilarious. Oh I got a meatball chip. Yes, so that's

great. Yep. Kind of sore official. Yes Y'all get y'all can start mailing it back and forth, you know different flavors of nasty chips All right, yeah pin pals All right, let's get back on topic We'll go down we'll go down a spiral here in a minute but uh, so I guess as far as the release goes When are you thinking you another couple months or you're thinking fairly soon on your release date? Don't like the official thing or or what's your feeling right now?

um, I mean there is a lot that I want to build in but that's kind of like it'll come and it will keep refining and there'll always be more because there's there's a Huge API footprint that we've got to kind of tackle to build all the stuff So I think it's just about getting a few of those key ones, you know It'd be great if we can get push notifications in our purchases The camera and a few other bits and pieces going and then I mean Android is that the other big piece, right?

So we get Android and those things and get everything kind of on par with each other and then it kind of feels ready Yeah, because right now it it's stable enough you know, I there is an app on the App Store that so the the principle of that is you could go today and and use it and build a product that you can sell like you could Sell it on the store or you could build it for a client that's paying you and you you know You're basically making money off this thing straight away, which is great

So I feel that it's like stable enough right now to do something But yeah, it's not gonna do all of the things that you might want to do with like interacting with the device API's so I Think once we've got some of those the stability is kind of already there Android will come and that'll just be like the okay, you know We've got the little cherry on top now

with everything working together. So let's just roll this out proper and then Then we can continue just like supporting it and maintaining it and improving it so I think We're probably looking at a couple of months from now But I definitely want to bring that in as much as I possibly can so get it get it going as quickly as possible basically Awesome. Well if so when people want to find out more

Where should they go? You know, I guess like a newsletter sign up or anything like that for them Yeah, the the easiest place to go to is native PHP comm slash iOS Because it is iOS at only at the moment But yeah, the the docs are coming together on native PHP comm got now like the whole section of like switching between desktop and mobile Documentation so you can start to see all of that come together And if you go to that page that I just mentioned, there's the chance to join the

early access program And there's a sign-up link there as well for a newsletter If you know you're not ready to join the early access program so you can find out more I'll be sharing updates and stuff on the newsletter over the coming weeks like probably once a week for the next few weeks Awesome. Well, man. Well, I appreciate you taking the time to you know, let us talk about native PHP iOS And I'm really glad to have the

opportunity again. Yeah, I'm excited I'm excited to see where this this you know brings the community in the future like we're it feels like there Connie you with all the announcements around Laravel proper announcements then you have you know what you're doing yet fusion you have and all this stuff is just Coming out of nowhere in the last year and it's it's pretty inspiring and I think we'll do a lot with people with Laravel in the future

Yeah, I can't wait to use fusion. I think Aaron said he's gonna bring it out on Friday I think he was gonna do it on Monday originally, but now it's gonna be this this Friday and I just I want to get my hands on that and chuck it into native PHP and see if it work on mobile out of the box because I think that's gonna be really cool because I think view You know, I've been showing most of my demos from like live wire because I really like using live wire but I used to do a lot of view and I know

there's like a space for still doing that and I think allowing people to use whatever front-end tooling Really makes sense and and there's nothing to stop you like I can't tell you you can't do it So, you know you can use view or react to whatever and and I think fusion will just slot right in there and just work and I just want to try it out so that I can see if that happens and I think that's gonna be very cool for a lot of people because

Yeah, Aaron did an awesome job. His talk was brilliant and the the project looks great, too So I'm really excited to see that For sure for sure all right, well Simon, thank you again for coming and joining me and We'll look look forward to the launch and to everything you're working on. Thanks, man

Transcript source: Provided by creator in RSS feed: download file
For the best experience, listen in Metacast app for iOS or Android