In this episode, the crew talks about enterprise applications, scalability, and productivity.
Transcription provided by https://twitter.com/wtoalabi
Intro: Alright welcome back to another episode of the Laravel Podcast, I am one of your hosts, Matt Stauffer, I have got two guys joining me...Can you introduce yourselves?
JEFFREY WAY: I am Jeffery Way!
TAYLOR OTWELL: And I am Taylor Otwell.
MATT STAUFFER: It's been a little while but we are back with a little bit more to share and if you haven't gotten a chance to check out the Laravel New...News Podcast...all laugh...Check out the Laravel new Podcast where...
MATT STAUFFER: Checkout the Laravel New..News Podcast...oh my gosh! Everytime now! News Podcast, where Jacob Bennett and Michael Dyrynda, basically being Australian and ' Illinoisian' tell you all the greatest and latest news that is going on with Laravel, so, because they are covering that so well, we are going off the beaten track a little bit talking about a few kinda broader topics, so, what we did was, we put out some requests on the Twitter account and said "Hey folks, what do you want us to talk about?"
And we picked a couple interesting ones and we just want to...just like the reader grab bag or... whatever you call it on your podcast Jeffery, so, the first one at the top of the queue is...something we hear about all the time, not just in this particular request, which is "Can Laravel be used for big apps?"
And sometimes this comes in the same conversation of well you know if you want to do enterprise you should use this framework or if you just want to do a cute little thing, then use Laravel.
You know, there are all this like statements and perceptions that people have and make about this, so before we go anywhere else, I would ask like, what is and do we know, what is the definition of an enterprise app, like if someone, and then again we are trying to give as much grace as possible to the person who actually thinks there is a distinction...what makes an enterprise app?
Is it about lines of code? Is it about patents? Is it about security? Is it about traffic? Like what makes something a big app? And or an enterprise app? Do you guys have a sense for that?
JEFFREY WAY: I really don't. So I basically have the same question. From afar, I will just say an enterprise app is something I imagine that is really really big...I don't know, it is an interesting distinction that people always make. I mean for as long as I can remember, even back in the Codeigniter days, you had this idea that Codeigniter is for these sorts of hobby projects but then if you are on the enterprise level, you are gonna reach for Zend or you are gonna reach for Symphony.
And I feel like even after all those years, I can't quite figure out, what specific features or functionality do they have, that make them suitable for enterprise or what would Codeigniter not have or what does Laravel not have...hmm... is it related to the fact that Zend has a big company behind it?
And whereas with Laravel, you know, like everyone is just gonna keep creating threads about ...what happens when Taylor dies? Is that the kind of idea? Like this is open source...it's kind of rickety...you are not sure what the state of it is, you are not sure if it's going to be abandoned?
And with Zend, maybe if you have a big company behind it..maybe you can depend upon it more? Maybe? I don't know, I have the same question as everyone else.
TAYLOR OTWELL Yeah, I think most people mean lots of classes I guess. You know, lots of code, lots of lines of code and I think the answers is, you know, obviously I am going to say yes it can be used for big apps, one because it has been used for big apps in the past, so we already know it's true basically.
But then also, I think that, you know, Laravel is good for any app that PHP is good for, so, Laravel gives you a good routing system and a way to route request as classes and sort of beyond that is really up to you, you know, once you are past the controller, you basically have total freedom to do whatever you want to do, so, it's up to you in terms of if your app is going to be scalable in terms of complexity. And also I think Laravel is kind of uniquely qualified and better at making big apps than other PHP offerings right now, for a few reasons.
One because when people start talking about big apps, a lot of time there is dependency complexity and Laravel Dependency Injection Container is really good and it's really thoroughly baked in throughout the entire framework. When you talk about complicated apps, a lot of time you are also talking about needs like background job processing and Laravel has basically the only baked in queue system out of any major framework in PHP...hmmm...and then of course there is event broadcasting and other features that I would say are more kind of on the big app side of things, so, not only is it...can it be used for big apps, I think it's uniquely better for big apps than other alternatives out there in PHP right now for those reasons.
And I think it's just a little misleading because it is easy to get started with, and has a very simple starting point. And since that has a single route file you can kind of jump into it and start hacking around on, but it also scales up, you know with your needs and with your team's needs in terms of complexity...so yeah, that's kind of my take on it.
Everyone kind of thinks that their app is a special snowflake you know, that has this, very unique requirements that have never been required in the history of web apps, but, the vast majority of applications don't have unique requirements and they don't really have unique needs and you know Laravel and many other frameworks really are going to be a good fit for them but I think Laravel is the best option in PHP right now for a big sophisticated application.
JEFFREY WAY: And it is funny because, for whatever reason everyone thinks their project is going to be the one that really put Laravel to the test in terms of how many page views it can render in a single second...all that stuff like...if you need to worry about that, you are at such high level and you will know if you need to worry about that or not, but 90, I would say 99% of projects will never even get close to that point.
So, it's almost like, to be frank, it's almost like a sense of vanity that you think the project you are working on right now is something that really needs to worry about that, because you probably are not even close.
TAYLOR OTWELL Yeah, and we are assuming, developers don't approach projects in a rational way, even though we think they might. Like people don't choose frameworks in a rational way, they don't choose anything really laughs related to tech in rational way, a lot of time, as surprising as that is.
There's a lot of things that go into it and some of it are sort of personality things, maybe they don't like a way that a certain framework is marketed or not marketed. You know some people are very turned off by active marketing around open source, so, maybe they don't like the style of Laravel sort of friendly, hey look at easy this is easy kind of marketing and they are turned off by that, and so they choose something that is more toned down, more sort of suite and tie like Zend because that fit's their personality better.
It's not really a technical decision, it's more of just personality or subjective decision. And that happens a lot with tech in general, you know, some people don't use anything that is popular in general, just the kind of classic hipster type thing. I think a lot goes into it and rarely is it purely technical. Sometimes it is... they don't like me! You know, they don't like me personally. And so they don't like Laravel or use Laravel.
JEFFREY WAY: I like you Taylor.
JEFFREY WAY: Right before we started recording, I guess RailsConf is going on and I was watching DHH give his presentation live...and he was kind of talking about this to some extent...the idea that it is important even for a tool like Rails or Laravel to have like their own culture and their own sense of values. And he was talking about how like a lot of people take this idea that you just learn all the different languages and then... you do...you are a programmer. So, if you need to work in this local language, you do it and you just apply everything over.
And he was talking about how like while that is true, what is wrong with being part of the community that has a very specific culture, very specific views...he talked about like the people that are still using Rails are doing it, maybe not just because it's better, but because they agree with the values that Rails represents. That is like the huge reason why people still use it to this day. And I think, that is very much true for Laravel as well. It is kind of interesting way to think about things. It's all personality, it's about what your values are. What you connect with and what you don't connect with.
TAYLOR OTWELL Yeah...when I first started Laravel, that was a big part of how I wanted, how I thought Laravel could be successful, because I knew that in my own life, like there is sort of this ongoing desire to sort of connect with a group of people. Some sort of community or whatever around shared values. And you know that can be found like around many different things like music, or sport or religion, or whatever.
And I knew with programming like I wanted to connect with this group of people that has similar values about writing really clean code and having a good time doing it and making it enjoyable and sort of interesting, new and fresh. And that's kind of how I presented Laravel and I think it resonated with some people that were also looking for a group with those kinds of values.
And that is still the kind of the values that we obviously try to share today, but yeah, it wasn't necessarily a purely technical thing, it was building this group of people that sort of resonates around similar ideas and working on it together.
MATT STAUFFER: It's interesting 'cos I think that even in my question, I conflicted big and enterprise and I think that you guys kind of really drew out the difference between the two in some of your answers, I mean if we think about it, like Jeffery's first answer was, while enterprise might be really interested in having a company back it versus a person..like Taylor said, we get the question of what if Taylor gets hit by a bus all the time.
And it makes sense right, like we have clients all the time coming to us like, say, you know well, you know the CEO or the board or the CFO of our multi-million dollar or multi-billion company are very worried that we are gonna invest a whole bunch of money and time in something and X ..and it's not always...and that Taylor might get run over by a bus, but a lot of developers are getting non-developer input on decisions they make here and there are certain times where some IT persons have set up some rules that says like
"You can only use projects like this and not [projects like that and I do wonder whether there are some constraints there like one of them being, that it must of be owned by a company, I know that when we worked with CraftCMS a lot of people said well, why would you, there's actually a business value of using CraftCMS over something Wordpress because Craft is making money and therefore it's a sustainable business model and therefore the business people are actually less worried about this thing disappearing. Right? So like maybe a more direct chain of profit to the people who are running the thing might actually make it clearer.
I don't know if that exists maybe ZendCon would be something like that but I know it's Laracon too...I don't really know!
But it's interesting that the requirements of ...like the true enterprise requirements...like because I work for a company, my company has these requirements...but I think people, including me when I ask these questions conflict that with big. And so I think there is a good place to take this next is, lets step away from enterprise a little bit...enterprise culture is a thing...you know whatever...let's talk about big, so the thing mentioned Taylor, and Jeffery both of you said a lot of people come along and say oh well mine is going to be the one that finally pushes those bounds right, I am gonna run into traffic issues and stuff like that, so, first of all, like I know that we can't say a lot of the names of big sites that are running on it but I feel like is there anything we can do to kind of like just ...
I mean, I know several of them 'cos I am under NDA with several of them, you know, who have talked to us about doing some work with us but there's like multi- I mean milions of millions of hundreds of millions of page views sites running on Laravel...there is like Alexa top 500 sites running on Laravel, there's ...hummmm...what's the big group of all the businesses in the US? I can't remember the name of it...Fortune 500 companies running on Laravel...like multiple Fortune 500 companies whose websites are running on Laravel. Are there anything that you guys can share, like to say, hey look, this is the proof, like we've got big stuff running through here.
TAYLOR OTWELL Trying to think some of them..I mean like the Vice Video, Log Swan, you know, various video games sites like FallOut 4 had their landing page on Laravel...other stuff like that, but you know, it's sort of never seems to be enough and it sorts of becomes this treadmill of, you know, I have to give one more proof that it sort of can work...and I just wonder like what's really underlining the question like, do they want to know that if I build my big app on Laravel will it be infinitely maintainable and clean...and no, Laravel won't automatically make your app amazing to maintain for 10 years, you know, I don't know if it's like trying to sort of scale responsibility for you also having to do a lot effort to like make your app enjoyable to maintain or what...but...
MATT STAUFFER: Bad programmer, can write a bad app with any framework right? Like, nothing is going to rescue you from that..not saying that the person asking is necessarily bad..but I think that's a great point you made earlier Taylor, I wish we can further into it, is that with Laravel like yea ok, Laravel has it's own conveniences but at some point every single app is basically just you writing PHP...
TAYLOR OTWELL: Yeah
MATT STAUFFER: And especially at this level when you are talking about hundreds of thousands of lines of code, like the vast majority of the dependencies there is going to be just PHP code right?
TAYLOR OTWELL: Yeah. Once you get...let's just take like a Laravel app...'laravel new'...whatever...once you are at the controller, method, in your controller class, everything else is up to you, so whether you use the validator or whether you even use Eloquent at all, or whether you use anything in Laravel, is entirely up you, so it was your choice to do whatever you did past that point.
So, it's not Laravel making you do any one particular thing. So, that's sort of the point where you are gonna have to, you know turn your thinking cap on and really plan on how to do a big project, because as far as the framework is concerned, the framework is gonna be a much smaller concern than your actual code, you know the framework is gonna be routing session, some caching, some database calls, but you are the one that is gonna have to like, figure out the domain problems of your app, which is gonna be way more complicated I think, than any framework problems you are gonna have.
Like, how is this app gonna work? How is it gonna provide value for our customers, or whatever, those are all like much bigger questions I think...than worrying about can Laravel be used for "Big" apps.
MATT STAUFFER: One of the questions we got on Twitter was, how to build big sites with Laravel, scaling, deployment, database structure, load balancing, so, lets say someone is on board right...yes, Laravel can be used for big apps period..it's good..so, what are some considerations that you would have, so if you were taking, you know, a default app out of the box and you "laravel new" it and you build some basic stuff and someone says alright, this app that you just built needs to be able to handle you know, a million hits a week next month..what are the first things you would look to, to start, kind of hardening it against that kind of traffic?
TAYLOR OTWELL: Hmm, really simple things you could do is to make sure you are using a good cache or session driver, so probably you wanna use something like Memcache or Redis or something that you can centralize on one server or Elasticache if you are on AWS whatever, you know, you are also probably gonna use a load balancer...PHP is really easy to deploy this way you know, to put a LoadBalancer up and to make a few PHP servers and to alternate traffic between them.
PHP makes it really simple to do that kind of scaling and then with Laravel, make sure you use config cache, make sure you are using the route cache, make sure you are doing composer dump autoload optimized, you know, really simple things you can do to sort of boost your application a little bit.
MATT STAUFFER: Jeffery, I know Laracast is pretty huge, you kinda in there day in, day out, so I know you are super focused on making sure that it's performing, especially related to maybe, let's say, databases and deployment, can you give me any kind of tips that you have there for people who are building new kind of high traffic apps that you have learned from developing Laracast?
JEFFREY WAY: Yeah, Laracast is surprisingly high traffic, if you look at the numbers. And I can tell you, not doing that much...just to be perfectly frank, beyond what Taylor said, a lot of that stuff is kind of the fundamentals...of using config cache...a lot of people will just deploy and stick with the file based cache driver...laughs..you will obviously have some issues with that...but, I am not doing anything that fancy.
A lot of it becomes basic stuffs like, people completely ignoring the size of their images...like that is always the very first one I bring up and it's such a 101 tip, but if you go from site to site, you can see it being abused immensely. There is so many ways to work it into your build process...or if not, just dragging a bunch of images into..like a Mac app...I am trying to think of the one I use...
TAYLOR OTWELL: Is it ImageOptim?
JEFFREY WAY: ImageOptim, yeah just, like when you deploy you can drag a bunch of images up there and it will automatically optimize them as best as it can. And you would be shocked how much benefit you can get from that...versus people who just take a 100kb image and they throw it into their project...you know it's funny that people will debate single quotes versus double quotes all day and then throw a 200kb image into their banner, you know, it makes no sense, people, are silly that way.
TAYLOR OTWELL: I think another great thing to do is separate out your database from your web server. If you are building anything, you know, that you care about...like in a real way, it can be good to do that..and sort of, if you don't do it from the start, it can be kind of, you know, scary to make the transition, because now you've got to move your live database to another server...but, there are tools out there to make it pretty easy, there are even free packages out there to make it pretty easy to back up your database, so, that has always been really nice for me to have that on a separate server.
So definitely if you are gonna have to start do that because it just makes it easier to do that scaling where if you wanna add a second server, you don't have this sort of funky situation where you have one webserver talking to another webserver because it has your database and all that other stuff where now if you want upgrade PHP you've got to upgrade PHP on the same server that your live database is running on...just scary situations like that...that, that would help you avoid.
MATT STAUFFER: Are you guys using a lot of caching on your common Eloquent Queries?
JEFFREY WAY: Yeah, I do quite a bit.
TAYLOR OTWELL: I really don't on Forge.
MATT STAUFFER: I wondered about Forge, because with Forge, each query is gonna be unique per user right? Versus with Jeffery where there might be like a page that lists out all of the episode and you might have 10, 000 people hit that same page. With Forge, it's more 10,000 people each seeing a totally different list right?
TAYLOR OTWELL Yeah, it is very dynamic. The one thing I do cache is the list of invoices from stripe because there is a stripe API call we have to make, so we do cache that.
JEFFREY WAY: Yeah me too.
TAYLOR OTWELL: But other than that I don't think I really do any caching. So, Jeffrey probably has more insight on that...?
JEFFREY WAY: Well I have a lot of the stuff on the Forum, because the forum just gets hammered...you will be surprised about how popular that forum is...
MATT STAUFFER: I won't be surprised because it shows up on the top results of everything.
JEFFREY WAY: I know and I do love finding my forum when am googling for my own ignorance. And I go to my own website to figure out how to do something which is a great feeling! But I do have some queries related to the forum that are pretty intense, a lot of like multiple joins, pulling in stuff, so I do cache that..even summary, I cache that every 10 minutes at a time.
Just to reduce the weight a little bit. I get a lot of use out of that stuff and then, yeah, of course, the type of stuff that doesn't just change like Categories or Channels or like Taylor was bringing up, there is no reason not to cache those things. And yes especially the invoices it's a great example, if you are making a network query every single time a page is hit, there is really no need to do that if it's going to be the exact same results...every single time give or take a change or two...so those are obvious cases where you want to cache it as long as you can.
TAYLOR OTWELL: How do you burst your cache on Laracast?
JEFFREY WAY: Whenever something cache bustable takes place...I guess...
TAYLOR OTWELL: Ok so I guess like whenever a new category is out and stuff, you just ...
JEFFREY WAY: When a new category is out yeah, as part of that I will just manually bust the cache...or no, I will automatically bust the cache...in other areas, it happens so rarely that I just boot up 'php artisan tinker' and do it myself....laughs...which is crappy, but no, anything more common like that, I will just automate it as part of the...whenever I update the database.
MATT STAUFFER: We are working on an app right now that has Varnish sitting in front of it. And so literately the code that is behind our Skype window right now is me writing a job that just wipes the Varnish cache either for the whole thing or for specific routes in response to us notifying that the change happens and that's an interesting thing because the cache is outside of Laravel app, but it's cached based on its routes...and so I have the ability to say...well, these particular changes are gonna modify these routes and I built an intelligent Job that kinda get sent out anytime we need those things.
So even when it is not within the app, even when it is not your Laravel cache, there is still a lot of ability to kind of put some heavy caches on. And in speaking of that kind of stuff cache busting, use the Version in mix all the time. I mean that is just, because then you can throw Varnish or whatever else and just do infinite cache on your assets.
JEFFREY WAY: But on that note, actually, I have been thinking about that, is there...can you guys tell me any real reason why when we are using Versioning, the file name itself needs to change? Because you are using that Mix helper function already to dynamically figure out what the version file is, so is there any reason why we can't just use a unique query string there, or not a unique query string but taking where we would change the file name to include the version, we just include it as part of the query string and then the file name always stays the same?
MATT STAUFFER: I know that HTML5 boiler plate used to do just query strings and I hadn't even thought about that, but that might be possible, where the files always stay the same but your...what's that JSON file that has the ....
JEFFREY WAY: JSON manifest...
MATT STAUFFER: Maybe that just adds the id into the new id to pass? And it's just like authoring comment or something like that?
JEFFREY WAY: Yeah, when you version the file, it creates, basically it gets like a Hash of the file that you just bundled up and then that gets included in the new file name...but every time you bundle if that changes, you will never know what that file name is called in your HTML so basically you can use this Mix helper function that Laravel provides that will dynamically read that JSON file and it will figure out, oh you want this file, well, here is the current hashed version and we return that...but yeah I have just been thinking lately like, is it kind of dumb that we keep creating a new file, when instead, the Mix manifest file can just have the relevant query string updated.
MATT STAUFFER: So, I googled really quick and there is a thing from Steve Souders....who is the guy who originated the 13 rules of make your website faster or whatever they were...the whole like, you know less HTTP requests, and it's called in your files names don't use query strings...I havent read it yet...oh High Performant websites...I havent read it yet and it is 9 years old.
My God! Now that I am seeing seen him talking about Squid, I have worked with Squid before which is like a pretty old cache, but a lot of stuff that works for Squid also works for Cloudflare so I am guessing Cloudflare is either using Squid or adopted Squids terminologies and I do think...and I also did a whole bunch of work with one of our clients who is writing custom Varnish rules right now. And I do remember that stripping query strings is a thing that happens sometimes especially when it doesn't matter, for example in the case of asset, I think it maybe a thing that he do by default, so he is digging through here and Squid and proxies and stuff like that, I think basically what he is saying is your proxy administrator could go and teach the proxy to care about query strings but all then ignore them by default...
JEFFREY WAY: Ok
MATT STAUFFER: So by choosing to use it with query strings you are opening up a lot of job opportunities where it doesn't work the way you are expecting.
TAYLOR OTWELL: I have been using Cloudflare quite a bit recently. The whole Laravel website is behind Cloudflare, heavy Cloudflare caching, very few requests actually hit the real server. Mainly because it's all static, you know documentation but am a big fan of that, especially when you are scaling out webservers, if you are using, you know, some kind of Cloudflare SSL.
I think Amazon has a similar SSL service now, it makes so much easier to add a web server because you don't really have to think about your certificates as much, you know, putting your certificate on every server, especially because since you can just use like a self-signed certificate if you are using the Cloudflare edge certificate...so that's something to look into and it's free to get started with and it has some nice feature for scaling.
MATT STAUFFER: I helped some folks at this thing called the Resistance Manual, which is a Wiki about basically...huh......sorry to be mildly political for a second...all the negative impact of the Trump presidency and how to kind of resist against those things. And so they wanted me to help them gather their information together and I said well I can help out, I am a tech guy and they were like, do you know, you know, media wiki, which is the open source platform behind things like Wikipedia, and I said no, but you know, I can learn it.
Turns out that it's like really old school janky procedure PHP and so I said yeah I can handle this but it is also just extremely dumb in terms of how it interacts with the database and so when you are getting you know millions of hits like they were on day one, we had a like a 8 core, you know, hundreds of hundreds of dollars a month Digital Ocean box and it was still just tanking.
Like couple of times a day that the caches were getting overflowed and all that kind of stuff, so, I threw clouldflare on it, hoping it would be magical and the problem with that is it's not Cloudflare's fault it's because Cloudflare or Squid or Varnish needs to have some kind of reasonable rules knowing when things have changed and for anyone who has never dealt with them before there is a sort of complicated but hopefully not too complicated dance between your proxy and reading things like expires headers and E-Tags and all that kind of stuff from your website.
And so if you throw something like Cloudflare or something like that on it and it is not working the way you expect, the first thing to look at is both the expires headers and the cache link headers that are coming off of your server pre-cloudflare and also what that same response looks like when it's coming back after going through cloudflare, and cloudflare or whoever else will add a couple of other ones like did it hit the cache or miss the cache and what's the expires headers and what's the Squids expires headers, so there are lots of headers that give you the ability when it just seems like it is not just working the way you want and there is only like 3 configuration options in cloudflare, then what do you do?
Go look at your headers and I bet that you know, 15 minutes of googling about how cloudflare headers work and Squid headers work and then inspecting all your headers before and after they hit cloudflare and you will be able to source out the problem.\ Alright so, we talked databases, we talked loadbalancing a little bit, deployment, so, if anybody is not familiar with zero downtime deployment, just a quick introduction for how it works...if you use deployments on something like Forge the default response when you push something new to your github branch is that it hits 'git pull', 'composer install' 'php artisan migrate' or whatever, so your site could erratically be down for seconds while the whole process runs and so, if you are worried about that you can run, 'php artisan down' beforehand and 'php artisan up' afterwards, so when it's down, instead of throwing an error, you just see like hey this site is temporary down kind of thing.
But if you are in a circumstances where that is a problem, you might want to consider something like Capistrano style or Envoyer style zero downtime deploy, look somewhere else for a much longer explanation but essentially, every time a new release comes out, it's cloned into a new directory, the whole installation is processed and run there and only once that is done, then the public directory that is getting served is symlinked into that new directory instead of the old one.
So you end up with you know with the last 10 releases each in its own directory and you can go back and roll back into a previous directory and Taylor's service Envoyer is basically a really nice User Interface in front of that...
For me that has always been the easiest way to handle deploys in a high kind of pressure high traffic high loads situations is just to use Envoyer or Capistrano.
Are there any other experiences you've all had or tips or anything about how to handle deploys in high traffic settings when you are really worried about you know those 15 seconds or whatever...are there any other considerations we should be thinking about? or anything?
TAYLOR OTWELL: That's the extent of my experience..I haven't had anything that is more demanding than using Envoyer. Am sure there is you know...if I were deploying to thousands of servers, but for me when I am just deploying to 4 or 5 servers Envoyer has been huh...pretty good bet.
MATT STAUFFER: And hopefully if you are deploying to a thousand sites, then you've got a server person who is doing that. You know like we are talking dev'ops for developers here right, like when you are running a minor server not when you are running a multi-billion dollar product and the clients I have been talking to were working with all these kind of Varnish stuff..I didnt setup Varnish you know, my client setup Varnish and took care of all these stuff and he just kinda asked me for an input in these kind of stuff and so I definitely would say like there is definitely a limit at which...you know...people often lament like how many responsibilities they are putting on developers these days.
I don't think we all have to be IT people capable of running servers for you know, a one thousand server setup for some massive startup or something like that. But I think like this whole, you know, how do I handle a thing big enough that 15 seconds of down time where a migration and composer run...I think that is often within our purview and I think something like Capistrano or Envoyer is for me at least it's being a good fix...the only situation I have not had to run into which I have heard people asked about online and I wanna see if you all have any experience there is, what if you do a roll out and it has a migration in it and then you need to roll back?
Is there an easy way to do the 'migrate:rollback' in an Envoyer rollback command or should you just go Envoyer rollback as you SSH in and then do 'php artisan migrate:rollback'
TAYLOR OTWELL: Sort of my view on that recently like over the past year has been that you will just never roll back, ever. And you will always go forward. So, because I don't know how you rollback without losing customer data. So, it's, a lot of time not really visible to rollback. Lets just pretend you could, then yes, there is no real easy way to do it on Envoyer, you will just kind have to SSH in and do php artisan rollback like you said.
But I think a lot of times, at least for like my own project like Forge and Envoyer, I can never really guarantee that I wasn't loosing data so I think if at all possible, what I would try to do is to write an entirely new migration that fixes whatever problem there is. And deploy that and it will just migrate forward, you know. And I will never really try to go backwards.
MATT STAUFFER: You find yourself in that accidental situation where you deploy something that should never have been, then you then go 'php artisan down' real quick, run the fix, push it up and let it go through the deploy process and then 'php artisan up' after that one deployed.
TAYLOR OTWELL: Yeah. That's what I would do. If it's, I mean, sometimes if it's low traffic and you feel pretty certain no one's messed with the new database schema, then probably you can just roll back, but, I was just worried in Forge's case that people are in there all day, I would lose data. So that's why I would every time possible to try and go forward.
MATT STAUFFER: Yeah, that makes sense.
TAYLOR OTWELL: I have actually stopped writing down methods in my migrations entirely recently...not that it's optional.
JEFFREY WAY: I feel evil doing that! Like I very much get the argument...but, when I create a migration and I just ignore the down method, I feel like, I am just doing something wrong. I am still doing it right now.
TAYLOR OTWELL: It's really mainly visible in Laravel 5.5 'cos you've got the new db:fresh method or db:fresh command, which just totally drops all the tables without running any down methods.
MATT STAUFFER: I end up doing that manually all the time anyway because at least in development, the most often when I want to do refresh, it's often in context where I still feel comfortable modifying old migrations..like basically, the moment I have run a migration in prod, I would never modify an old migration. The moment there is somebody else working on the project with me, I will never modify an old one unless I have to and it's just so important that I have to say hey, you know, lets go refresh.
But often when I am just starting something out and I have got my first 6 migrations out, I will go back and hack those things over and over again...I don't need to add a migration that has a single alter in it, when I can just go back and edit the thing. And in that context often, I change the migration and then I try to roll back, and sometimes I have changed it in such a way where the rollback doesn't work anymore. I rename the table or something like that...
JEFFREY WAY: Right....
MATT STAUFFER: So fresh is definitely going to be a breath of fresh air.
JEFFREY WAY: I do wish there was maybe a way to consolidate things, like when you have a project that has been going on for a few years, you can end up in a situation where your migrations folder is huge...you just have so many. And it's like every time you need to boot it up, you are running through all of those and like you said sometimes, just the things you've done doesn't just quite work anymore and you can't rollback.
It would be nice sometimes if you could just have like...like a reboot, like just consolidate all of these down to something very very simple.
MATT STAUFFER: We did that with Karani I don't know if there is...there is a tool that we used that helps you generate Laravel migrations from Schema and we did it soon after we had migrated from Codeigniter to Laravel for our database access layer. Karani is a Codeigniter app where I eventually started bringing in Laravel components and then now, the actual core of the app is in Laravel and there is just like a third of the route that are still on Codeigniter that havent been moved over and once we got to the point where half of our migrations were Codeigniter and half of them were in Laravel it's just such a mess so we found this tool...whatever it was.
We exported the whole thing down to a single migration, archived all the old ones, I mean, we have them on git if we ever need them and now, there is just one..you know, one date from where you just get this massive thing, and then all of our migrations happen kind of, from that date. And for me, I actually feel more free to do that when it's in production because the moment it's in production, I have less concern about being able to speed it up through this specific process because like if something is from two months ago, I am sure it had already has been run in production and so I feel less worry about making sure the history of it still sticks around...
JEFFREY WAY: Alright...right...
MATT STAUFFER: Alright...so the next question we have coming up is, "I will like to hear about how you all stay productive." And we've talked on and off at various times about what we use..I know we've got us some Todoist love and I know we've got some WunderList
I've have some thoughts about Calendar versus Todo lists and I also saw something about Microsoft buying and potentially ruining Wunderlist..so what do y'all use and what happened with Wunderlist.
TAYLOR OTWELL: Well, Todo lists are dead now that Wunderlist is dead.
MATT STAUFFER: Yeah...So what happened?
TAYLOR OTWELL: Wunderlist was my preferred todo list, I just thought it looked pretty good...and Microsoft bought them I think, that was actually little while back that they bought them but now they have finally announced what they are actually doing with it...they are basically shutting down Wunderlist and turning it into Microsoft Todo...which doesn't look a lot like the old Wunderlist and doesn't have some of the features of the old Wunderlist...but it looked ok..you know, it seems fun, so what I have done is migrated to Todoist rather reluctantly but it's working out ok.
JEFFREY WAY: Please correct me...is this funny like, Wunderlist is gonna be around for a very long time but just the idea that they are shutting down it's almost like you feel compelled...we've talked about this with other things too...where it's like you suddenly feel like oh I need to migrate...we talked about it with Sublime, like if we find out tomorrow, Sublime is dead in the water.
But you can still use it as long as you want. Even though, it would still work great, you would have this feeling like well, I gotta get over to Atom or I gotta start moving on...'cos this place is dead, even though Wunderlist is gonna work for a long time.
TAYLOR OTWELL: Yes...laughs...as soon as it was announced, I basically deleted Wunderlist off my computer...
TAYLOR OTWELL: Which makes no sense, but it's so true...
MATT STAUFFER: I needed a new router and everyone told me, you use the Apple Routers 'cos they are the best...but I have heard they are 'end-of-life'd'....and I was like no way...no way I am gonna throw all my money there and someone say well, why does it matter...you know...you are gonna buy a router and you are gonna use it till it dies?
And I said I don't care...I am gonna buy something else 'cos it just...I don't know...it's just like you are putting your energy and your effort after something that can't...you know can only be around for so long and you just want..you want be working with something that's gonna last I guess...
JEFFREY WAY: Yeah...I am still on Wunderlist right now. I am hearing...humm..if you guys are familiar with "Things" that was like the big Todo app years ago...and then they have been working on Things 3 or third version for a year...it's been so long, that people joke about it..you know, it's almost like that...new version of..humm..what was it...there was hummm...some Duke Nukem game that....
TAYLOR OTWELL: Is it Duke Nukem Forever..?
JEFFREY WAY: Yes! For like 10 or fifteen years and it finally came out! It's looking like next month, "Things 3" will be out and I am hearing it..like the prettiest ToDo app ever made I am hearing really good things. So, I was hoping to get in on the beta but, they skipped over me. So, I will experience it in May but I am excited about it. So, that's the next one..but you know what, I am never happy with Todo apps..I don't know why. It's kinda of weird addiction...if you say an item address basic need...even like a Microsoft Todo.
Ok, your most basic need would be to like say...Go to the market on Thursday. You can't do that in Microsoft Todo. You have to manually like set the due date to Thursday. Rather than just using human speech.
TAYLOR OTWELL: Have you tried Todoist?
JEFFREY WAY: Todoist works that way. Huh I think Wunderlist works that way but now, Microsoft Todo doesn't.
MATT STAUFFER: Oh ok..got it. You lost that ability right?
JEFFREY WAY: Yeah, it's so weird like every task app would have something that's really great and then other basic things that are completely missing...and it's been that way for years.
MATT STAUFFER: I always feel bad, I mean I bought things...thankfully I managed to skip...what was that thing...OminiFocus, I skipped OminiFocus which is good 'cos that is hundreds of dollars saved for me. And I tried...I tried all these different things and I finally figured out that there is a reason why I keep jumping from one to the other, is because..for me...this is not true for everybody...and I think it might have to do with personality a little bit...and the industry a little bit, and what your roles are whatever, Todo lists are fundamentally flawed because they are not the way I approach the day...and they are not the place my brain is...so, I can force my brain into a new paradigm for even a week at a time but I have never been able to stick with it and it's not the app, I thought it was the app, I thought just once I get the right app, I will become a todolist person and I realized, I am not a Todolist person so I can try every app and it can be perfect and I will still just stop using it 'cos it's not what I think about.
And when I discovered that I can't use and then later found some articles talking about how I am not the only person who come up with this...that validated me...'cos I put it on my calendar and so, if I need to do something, I put it on my calendar and then it gets done. And if I don't put it on my calendar, it doesn't get done. End of story.
It's so effective for me that my wife knows at this point that if she asks me to do something and I don't immediately pick up my phone and put it on my calendar, she knows it's not gonna get done. Because that's..that's how things happen and so, it's amazing to me, that..laughs...she literarily, when she first started discovering this, she sent..and she's not not super technical..like she's smart, she just doesn't like computers all that much...but she knows how to use google..and so, she, when she first discovered this, she sent me a calendar invite that is "Matt Clean Toilet"...and it's for 8 hours every Sunday and so, I will be on a screenshare..'cos she's like that's how I am ever going to clean the toillet right?...so I will be on this screenshare with a client and I will pull up my calendar and to say hey when is it a good time for us to have this meeting? And I will be like..oh "Matt Clean Toilet" takes the 8 hours....laughs...
But for me, my todo list is my calendar.
And everyone kinda in the company knows what my calendar is completely for and Dan actually has asked me to start marking those things as not busy, so, Calendly, our appointment app will still allow people to book...like clients to book times with me during that time..but like essentially, if I need to get something done, like, I..I need to review a whole bunch of pull requests, like Daniel who works with me literarily just put meeting invite on my calendar for tomorrow 10:30 and it says "Code Review @ Daniel".
And literarily after this podcast, there is an hour that says "Code Review with James" because they know that that's how they get it....and there is...500 hundred emails in my inbox and all these other things I have to do, but if it goes to the calendar, it gets done.
So, have you guys ever tried that? Does it sound like something that will click with you or no?
JEFFREY WAY: I think it makes good sense for you because it sounds like your days are scheduled like your day is full..humm...my day isn't quite as much like do this with so and so, I don't have as many meetings. So, most of my day is like: these are the things I wanna get done. And it doesn't matter whether I do it at 9:AM or 9:PM, so, Todo list works good for me but yeah..I can see how like if my day was very segmented and scheduled that would make far more sense than reaching for some todo app.
TAYLOR OTWELL: Yeah..my days are usually pretty free-form outside of the kinda standard schedule where I always do emails and pull requests first thing in the morning but then after that lately it's been...you know..was work on Horizon..now it's work on the thing that comes after Horizon, and that's pretty much the rest of the day, you know, besides whatever Laracon stuff that I have to do recently, which is more of a seasonal thing you know.
But I got lunch, all booked, that's done...but whatever we need, you know, furniture, catering or whatever. But yeah, then I pretty much just work on one thing throughout the day. So, I don't really switch context like that a lot. But I was so despondent at the Wunderlist announcement that all Friday afternoon I wrote a chrome extension that when you open new tab, it opens "Discussing Todo List" that I wrote in VueJs and you know HTML and it uses the chrome sync to sync it across my chrome account to all my laptops whatever...so... every new tab has a todo list, but even that, I was still not happy with it and deleted it and the whole afternoon went with the todo list. Anyway, but I have forgotten about the Chrome extension thing. I need to open source it.
MATT STAUFFER: Every developer has to make their own Todo list at some point in their lives.
TAYLOR OTWELL: Yeah. That's interesting about the calendar though...I want to get Calendly because it looks like a really cool app and try some more calendar stuff 'cos I haven't really dug into that as much as I could.
MATT STAUFFER: Yeah...I use basic Calfor my desktop app, I know that, I think I use Fantastic Cal on the phone or something..a lot of people love that...the thing that we like about Calendly is that it gives me a public link that syncs up to my Google calendar and so when we need to schedule things like we are in the middle of hiring right now or client meetings, I just send them to my calendly link and I just say, go here and schedule time with me and it syncs up with my Google calendar and it shows them all the times and I can say..go schedule a 60 minutes meeting and I give them the 60 minutes link or 5 minutes or whatever and you can put different rules around each.
So I teach calendly when do I drop my son off at school and when do I ...you know drive from my home office to my work office all that kind of stuff...so that it knows when I am available and then..because we just wasted so much time between Dan and me trying to get our calendars in sync. So, that's what I love about Calendly.
TAYLOR OTWELL: What really sold you on basic Cal over like you know just Apple Calendar or whatever?
MATT STAUFFER: I wish I can tell you...I know that it handles multiple calendars better...but it's been so long since I made that choice that I couldn't even tell you. I know that Dan, my business partner hates calendars more than any person I have ever met and almost every time he complains about something, I am like oh yeah, you can do that with Basic Cal and he is like "I still use Apple Calendars" I know those things but I can't tell you what they are..so.
Alright...so one last question before we go for the day. Saeb asked "It would be nice to hear why are guys are programmers. Is it just something you love and enjoy or is it just a way to put bread on the table? Is it passion what is it that makes you wanna be a programmers?"
JEFFREY WAY: I will go first. I fell into it. I think we are being disingenuous if we don't say that to some extent...but I know even from when I was a kid, I love the act of solving puzzles. I remember I had this Sherlock Holmes book and it's one of those things where every single page is some little such and such happens...somebody was murdered and then Sherlock comes, points to so and so and says you are the person who did it. And the last sentence is always..."How did he know?!"
And that was like my favorite book.
I would go through it every day and try to figure out how how did he figure out that this was the guy who...you know...robbed the bank or whatever it happened it be. So, between that or I play guitar for over a decade and I went to school for that. It's all still the same thing of like trying to solve puzzles trying to solve riddles trying to figure out how to connect these things. You may not know it with guitar but the same thing is true, like puzzles and you start learning about shapes on the guitar and how to transpose this to this. And how to play this scale in eight different ways...it's still like the same thing to me it's figuring out how to solve these little puzzles.
And so for programming, I feel like it's the perfect mix of all of that. There needs to ne some level of creativity involved for me to be interested in it....I always worried I would end up in a job where I just did the same and only this thing every single day. And I would finish the day and come back tomorrow and I am gonna do the exact same thing all over again. So there needs to be some level of creativity there which programming does amazingly well or offers amazingly well. Although my mum would never know.
I think she thinks I gave up on music and went to this like boring computer job...and even though when I explain to her like no there is huge amounts of creativity in this I don't think she quite makes the connection of how that is. So, yeah, between the creativity and solving puzzles, and making things, it's a perfect mix for my personality.
TAYLOR OTWELL: I was always really into computers and games and stuffs growing up, so it was pretty natural for me to major you know in IT in college but I didn't really get exposed to the sort of the front side of programming and open source stuff until after college when I started poking around on side projects and stuff like that.
So, I did kind of fall into this side of programming you know, where, you are programming for fun as a hobby and working on open source after I graduated but I was always kind of interested in looking back sort of things that are similar to programming so like into games like SimCity and stuff like that where you are planning out you know, your city and sort of...one of the similar things you do when you are building up big projects or whatever a big enterprise project you know was sort of planning and trying to get... just the right structure whatever, so I was kinda always into that thing. And just sort of naturally fall into that path later in life.
MATT STAUFFER: I...my brother and I started a bulletin boards service...out of our spare bedroom, I mean we were in Elementary or middle school or something like that..and he is 3 and half years older than me and he is a little bit more kind of like intellectual than I am, so, he learned how to code the things and he said why don't you be the designer.
And that kind of trend just kept up. When he learned how to make websites, he be like well, I am gonna make websites and you be the designer. And so I kinda had this internalized idea that A...I was interested in tech..but B, I was the design mind. And the thing is, I am not a very good designer...like the only reason I kept getting into design is because I had like...
I was creative, I was a musician and stuff but also because my brother already had the programming skills down and so he needs a designer right? And so, I think that I went off to college, by that point I already had a job as a programmer, I already had my own clients, doing you know frontend web developments and basic PHP, Wordpress that kind of stuff but I was like well I need to become a better designer so I went off to college for design and I just realized I am not a designer, so I left.
And I went off and I did English and I worked with people and I worked for a non-profit having thought you know like oh that is not my thing and then I kinda did a turn round when I left the non-profit, my wife went back to school and I needed to pay the bills, so it was..there is an element of paying the bills..I say like well I know that web development pays well, so I will go back to that.
And just discovered that I love web development...it is fulfilling and it is satisfying...it is creative...it's using your brain in all this really interesting ways...each one it's a little bit the same, a little bit unique, there is always really great things about it...I mean I remember one of the things that drove me nuts about my previous work..both in design and in working in the non-profit is that there is no sense like whether you did a good job or not.
There is no sense of when something is done. You are just very kinda of vague and vacuous and with this, it's like there is a defined challenge...and you know when it's done. And you know whether you did a good job or not. And I was just like that was huge...that was so foundationally helpful for me.
And so I think just kind of being able to approach it and realize that it's creative..like, it's creative and it is well defined..it's a little concrete..it's a challenge all those things together I think for me..and it turns out that it wasn't just a way to make money and I have also since discovered now that I run a company that I also have all the people aspects here..it's about relationship, it's about communities...I mean we have talked about that a lot in this episode and running a company is about hiring and company culture and all those kind of stuff...
So I get to comment especially at the level of tech that I get to do day to day whether it's open source or running company I feel like it's all of the best together in one word.
JEFFREY WAY: So Matt, how did you go from taking on smaller projects when you went back to web developments to suddenly running Tighten? Like how did you get there? What happened? Were you getting more projects than you can handle?
MATT STAUFFER: The opposite. I...I had no work. I worked out of a co-working space in Chicago and I only had about 10 hours a day, fifteen hours day filled because I didnt know anybody. And I had not been doing anything in the industry for 6 years.
So, I said, you know what? When I worked for non-profit there was this need I had and I still worked for those non-profit's per time at that point, so I just started building an app...I built an app by hand while I worked for the non-profit in PHP and it was terrible. And I was like oh, I have heard about this framework thing, and so I tried building it in CakePHP and it was terrible, and so, those experiences matured me a little bit...and so by the time I was now kinda going solo as a developer, every free moment I would have, outside of the you know, the contract work I had, I would go learn Codeigniter.
You know my buddy Matt had learned ExpressionEngine and said hey, checkout Codeigniter I think you might like it. So I learned Codeigniter and I did all these work in Codeigniter and I built this whole app which is Karani, the thing we are talking about today and I built Karani and I made it for myself and then my friends wanted it and so then I made it for my friends and then it was costing me money to upkeep, so I learned how to charge them money..and Stripe was brand new at that point, so I almost went with Stripe but I ended up going with BrainTree...I got into like big and software as a service app development through there...and right at that same time...
I was teaching my buddy all about modern web development HTML5 boiler plate all that kind of stuff after work one day and this guy walked over...the one guy in my co-working space that I had never met, who was always in his closed office and he was like, are you a developer? Are you looking for work? I was like yeah..and he was like..I need you...would you consider working for me?
I played it all cool but I was like YES..PLEASE I NEED WORK!!! I only have 10 hours of work a week right now. And it was Dan...
And so, Dan and I worked together on this massive project for a year and the client took 6 months to actually get the work ready for us. And he already had me booked and he already had me billed and he was why don't you just go learn become the best possible developer you can..I will throw you know, 30 hours a week jobs just off my various you know various projects...but in all your free time and even in those projects, just learn to become the absolute best, because we were working for, you know, this massive billion dollar international company at that point.
And responsive was like just a thought in people's minds. So, I wrote you know, articles and I created responsive libraries back in the early days of responsive and all those kind of stuff and I was like really up in the middle of it. And then we built this app.
So, I had like a lot of kind of things that took me very quickly from like hey I haven't written any code or any professional code in 6 years to like to the point where I was ready to build an app for this billion dollar company.
JEFFREY WAY: That was amazing. That is how learn best too.
MATT STAUFFER: It really is..and Dan and I loved working together so well that within 6 months we decided to go into business together and 6 months or a year later, we named it Tighten and the rest is history.
MATT STAUFFER: And so, we are super late and Jeffery, you are the one who has to edit this all later, so I apologize for that..so Ok. Future Jeffery, editing this, I am going to do you a favor, call it a day for now so..guys...it's been a ton of fun..everyone who submitted questions to us on Twitter, the ones we didn't get to today, they are still on our trailer board, we will get to some of them next time...
But keep sending us stuff for us to talk about and like I said, the Laravel news podcast is doing a fantastic job of keeping you up to date on regular basis with news so definitely tune in there for that...but we are gonna be talking about more long form stuffs when you got questions for us, send them to us either to our personal accounts or twitter account..for the podcast and we will try to get to them whenever we can..so, until next time..it's Laravel Podcast thanks for listening.
MUSIC fades out...