Good non-vitriolic post with "it-depends" mentality, which I think is rare to see in an article these days. Hard lines in the sand get more clicks, but it's not the nature of day-to-day development.
When writing side-project-type code, I'll tend toward the second example, but make sure there are both integration and unit tests to back them up. If the project gets to a point where it goes toward the first example, the integration tests should still pass, with additional tests to confirm the correct events were dispatched, exceptions were thrown, etc. It's rare for my personal projects (and covered in your article—throw-away project, etc.), but it's happened.
I imagine that could be covered in a latter post, as suggested in this:
These are just simple code examples to illustrate the idea, we’ll get back to this topic at some point when we look at a more complex use case where a more complex code sample will be refactored.
In that post, a suggestion (based on my job at the moment 🙊): the complex sample code also has no existing code coverage :P
It's 100% worth it. while the videos may be a bit dated, the concepts carry through. I'd say it's the Laravel equivalent of https://www.railstutorial.org/, which is _the_ definitive TDD course for Rails.
Test Driven Laravel takes it a step further, imo—its biggest positive is it teaches how to mock / test 3rd party APIs (stripe), which never gets covered in other TDD courses and is when actual TDD breaks down (TDD isn't hard until mocking becomes complicated).
Are there any issues you’ve ever run into with this? In my freelance career, I always deal with stripe which does the same, so I’ve always done cents that convert to dollars / whatever. But in my daily job, another team does it with floats and rounds on their own. This might be naive but ints seem so much easier to deal with … can you think of any reason to deal with floats if you’re only dealing with third party apis?
As someone that originally developed in Rails (5 years ago, caveat emptor), developing in Rails was somewhat of a pain because of its asset pipeline. It was incredibly coupled to the framework, and just as opinionated as the framework itself, which made breaking out of the pipeline pretty difficult as more functionality was needed. Webpacker was a step in the right direction, utilizing community-standardized front-end tools to handle compilation instead of completely coupling it to the framework, but it's still pretty opinionated. It seems importmaps is another step in the right direction, but may ultimately still be pretty coupled from what I'm reading.
In contrast, Laravel has no opinions about the frontend. It has suggestions, e.g. Livewire, Inertia, etc., but you are free to use whatever front-end build tools you want to handle your app. After working with other, more opinionated, full-stack frameworks, this is the way (for me).
I used to feel that way. What helped me was spinning up a couple of throwaway projects using all of them to see what jives with your mental model best. To get a good sense of things, push the throwaway a little further than a simple "to do" app—something with nested / shared components, relationships, etc. should be enough, though.
If you're hell-bent on a portfolio in Laravel, check out Statamic. It's kind of a best of both worlds scenario—flat file based CMS, with the ability to drop down into Laravel when you need it.
I'm using it on my portfolio and find it's nice to have the ability to create a barebones API using Sushi for smaller portfolio demos that don't warrant a full API / database-backed model.
Here’s one I wish for but have never seen mentioned: syntactic sugar for getters and setters. Something like Ruby’s attr_accessor or C#’s get, set would help decrease cognitive load of a class
from a business perspective, if you should decide to wrap your code in a docker container and provide opportunities to deploy to users' servers, **that is definitely a value add and you should charge accordingly**. See Atlassian's business model with cloud vs hosted solutions for a good idea of how to charge accordingly.
From a deployment perspective, docker is definitely a solid wrapper with low-ish overhead. Check out https://serversforhackers.com/ for some ideas on setting up your repository.
I imagine this is a counterpoint to a lot of the replies in this sub, so hopefully it adds some value (or another perspective, at least). I use vim as my daily editor for Laravel, ExpressionEngine and Magento 2 projects daily. What follows are my findings based on using the big three: VSCode, PHPStorm and vim.
In my vim setup, I have the ability to view a git blame line-by-line, add git changes and push to github without leaving the editor. That functionality is added via vim-fugitive, a plugin by Tim Pope. I'm also able to jump to inherited classes or interfaces via a combination of vim-gutentags, vim-laravel and the PHP language server. I get autocompletion of methods or classes via the same plugins. UltiSnips provides snippets so I can add new classes, tests or xml tags easily. And vim-projectionist allows for auto-injecting text based on the folder I'm in, so a Laravel model or controller gets populated with all the boilerplate out of the box. I'm as fast (or faster) than a lot of my team in the editor, based on workflows I've been using over years with vim and tmux. In short: you can pry vim from my cold dead hands.
However. VSCode and PHPStorm already have a lot of integrations built-in that I had to manually curate in my dotfiles. And installing new plugins are a couple of mouse clicks (or keystrokes) away, which are a lot easier to install than via vim-plug or whatever.
Vim as an IDE is a second-class citizen. I've built up my dotfiles over several (yes, 3, maybe more) years, across different languages and interests. And with every new language attempted comes the need to install more plugins to so that things work as expected. But I love building and tinkering with my vim workflow, so vim is for me.
If curating your dotfiles is a masochistic hobby and you enjoy the process, it's possible to get to IDE-level functionality with vim. But if you just need to get shit DONE (i.e. work), a preconfigured IDE is the way to go.
Also, here's how I got to near the same speed in VSCode that I have in vim (key combos to do different things):
Install the vim emulator for VSCode, it's very good. I have run into issues with undo/redo, however.
Open vertical split: ctrl + |
Open horizontal split: ctrl + k, ctrl + |
Switch to your first split … n split: ctrl + 1 … ctrl + n
Open a terminal: ctrl + ~
VSCode uses tabs by default, to switch between press ctrl + tab or ctrl + shift + tab
Try building a URL shortener. The basic concept is pretty simple—a user submits a long URL and is given a short URL that redirects to the user’s original URL.
If that is too easy for you, you can always track clicks to the short URL and provide analytics for how many users clicked it, time clicked, browser used, etc.
Quick aside: while I appreciate your boss wanting you to learn programming concepts such as conditionals, they don’t have much place in test code. Tests should be easily readable and self-documenting on what they are setting up, acting on, and asserting. Conditionals obfuscate the code under test—if you’re reaching for a conditional in a test you should break it into two tests
Honestly, because I didn't know it existed heheh. I guess the helper test method could be this instead, then (a nicely readable one-liner):
private function validParams($overrides = [])
{
return array_merge(factory(App\Post::class)->raw(), $overrides);
}
I'm open to using it, but want to mention for others reading this that the above may start to suffer from mystery guest; that is, a factory's valid attributes become so decoupled from the test verification logic, you can't figure out why things may be failing.
I tend to keep reusable methods in my tests to a minimum by default, as a way to combat hiding complexity in my apps. A good smell test for me is a long test--the longer the test (especially the test setup), the more likely the underlying class being tested is doing too much.
that said, the most my reusable methods ever do tend to deal with filling out valid parameters. here's an example:
public function thisIsAnInvalidTest() {
$response = $this->post('/posts', $this->validParams(['title' => null]));
$response->assertSessionHasErrors();
// ... etc.
}
One thing I'd probably do is combine the month/date/year fields client-side and send over a 'date' field, just so you don't have to build / parse that in the controller. Same deal with the avatar, if it's possible I try to only send over exactly the fields I need so unsetting isn't needed. Honestly that's just nitpicking, on the whole everything looks pretty clean; some parts of the app (especially those dealing with user input) are just going to feel a bit gross.
I use RESTful routing conventions that come out of the box with Laravel's scaffolding. In your case, a password is part of either a User or Account model. So there'd be an associated UsersController or AccountsController, with a put/patch request to update (update being the name I'd use as the controller action).
I originally got this convention from thoughtbot's Upcase, a monthly rails dev bootcamp-type deal.This post by Adam Wathan, "There's a Model Hiding in your Rest API, also really drives home the point that, if you're trying to shoehorn a "create" method in a controller that the "create" verb doesn't make sense in, it might mean you're missing something in your app's domain.
You're not getting closer yet, but I can see you're trying!
It isn't a question of weight w/ regards of SEO, it's a question of grouping. In the context of data, Posts shouldn't be grouped the same as Movies should be grouped. Movies have a different data structure that Posts or Pages just don't have: Year released, Genre, Director, Trailer, etc.
Movies (and Posts) are for similar content; Pages are for individual pages.
The thing is, Movies are not a post type within WordPress; so, the plugin Pods utilizes Custom Post Types to create a new Custom Post Type called Movies with the aforementioned data structure.
Note that yes, even with a Custom Post Type, you still need to fill in meta, title and page descriptions for each. This is indeed tedious, but it should be approached with the same care you took towards creating the blog post / whatever you are creating. Using the Yoast SEO plugin might help with crafting meta information that is better from an SEO standpoint.
I'm a fan of CF7—I didn't enjoy all of the bloat that Gravity Forms came with out of the box. CF7 is very basic, which fit my needs perfectly. Not to mention it's free :)
If you do end up going the CF7 route, I'd suggest CF7 Honeypot for simple spam protection, and Takayuki Miyoshi's other plugin, Flamingo, for managing the inbound messages that come through CF7 / simple CRM management.
It's a one-time $99 for as many local sites as you want, one production site. That $99 includes all minor version bumps, a major release is a new charge.
edit: info gotten from the laravel podcast, I'm not sure where/if that info is on the site
#4 is the best of the bunch by far! reason being, the categories are clearly delineated and easy to parse (different colors, etc). take from that what you will!
this isn't related to async, it's related to JavaScript's interpreter. See https://wsvincent.com/javascript-temporal-dead-zone/
aside: it’s likely your project is writing logs which could be why your disk space is filling up
https://www.vincentpontier.com/elephpant/ this is the "official" elephpant. Unfortunately as you've noted, they're currently out of stock. The one on elephpant.co.uk and phpclasses.org are knock-offs … you may not care, but if you do, be warned.
What a perfect use-case for LLMs
speaking of LLMs, copy-paste your code into Chat GPT and ask it if there are any security vulnerabilities ;)
Refactoring is the biggest one.
alt/option + enterDebugging is also better imo …
I don't personally use these, but I've seen some PhpStorm wizards use them enough to know they're worth using:
Good non-vitriolic post with "it-depends" mentality, which I think is rare to see in an article these days. Hard lines in the sand get more clicks, but it's not the nature of day-to-day development.
When writing side-project-type code, I'll tend toward the second example, but make sure there are both integration and unit tests to back them up. If the project gets to a point where it goes toward the first example, the integration tests should still pass, with additional tests to confirm the correct events were dispatched, exceptions were thrown, etc. It's rare for my personal projects (and covered in your article—throw-away project, etc.), but it's happened.
I imagine that could be covered in a latter post, as suggested in this:
In that post, a suggestion (based on my job at the moment 🙊): the complex sample code also has no existing code coverage :P
It's 100% worth it. while the videos may be a bit dated, the concepts carry through. I'd say it's the Laravel equivalent of https://www.railstutorial.org/, which is _the_ definitive TDD course for Rails.
Test Driven Laravel takes it a step further, imo—its biggest positive is it teaches how to mock / test 3rd party APIs (stripe), which never gets covered in other TDD courses and is when actual TDD breaks down (TDD isn't hard until mocking becomes complicated).
Are there any issues you’ve ever run into with this? In my freelance career, I always deal with stripe which does the same, so I’ve always done cents that convert to dollars / whatever. But in my daily job, another team does it with floats and rounds on their own. This might be naive but ints seem so much easier to deal with … can you think of any reason to deal with floats if you’re only dealing with third party apis?
Laravel already has these answers.
As someone that originally developed in Rails (5 years ago, caveat emptor), developing in Rails was somewhat of a pain because of its asset pipeline. It was incredibly coupled to the framework, and just as opinionated as the framework itself, which made breaking out of the pipeline pretty difficult as more functionality was needed. Webpacker was a step in the right direction, utilizing community-standardized front-end tools to handle compilation instead of completely coupling it to the framework, but it's still pretty opinionated. It seems
importmapsis another step in the right direction, but may ultimately still be pretty coupled from what I'm reading.In contrast, Laravel has no opinions about the frontend. It has suggestions, e.g. Livewire, Inertia, etc., but you are free to use whatever front-end build tools you want to handle your app. After working with other, more opinionated, full-stack frameworks, this is the way (for me).
I used to feel that way. What helped me was spinning up a couple of throwaway projects using all of them to see what jives with your mental model best. To get a good sense of things, push the throwaway a little further than a simple "to do" app—something with nested / shared components, relationships, etc. should be enough, though.
If you're hell-bent on a portfolio in Laravel, check out Statamic. It's kind of a best of both worlds scenario—flat file based CMS, with the ability to drop down into Laravel when you need it.
I'm using it on my portfolio and find it's nice to have the ability to create a barebones API using Sushi for smaller portfolio demos that don't warrant a full API / database-backed model.
Here’s one I wish for but have never seen mentioned: syntactic sugar for getters and setters. Something like Ruby’s attr_accessor or C#’s get, set would help decrease cognitive load of a class
from a business perspective, if you should decide to wrap your code in a docker container and provide opportunities to deploy to users' servers, **that is definitely a value add and you should charge accordingly**. See Atlassian's business model with cloud vs hosted solutions for a good idea of how to charge accordingly.
From a deployment perspective, docker is definitely a solid wrapper with low-ish overhead. Check out https://serversforhackers.com/ for some ideas on setting up your repository.
I imagine this is a counterpoint to a lot of the replies in this sub, so hopefully it adds some value (or another perspective, at least). I use vim as my daily editor for Laravel, ExpressionEngine and Magento 2 projects daily. What follows are my findings based on using the big three: VSCode, PHPStorm and vim.
In my vim setup, I have the ability to view a
git blameline-by-line, add git changes and push to github without leaving the editor. That functionality is added viavim-fugitive, a plugin by Tim Pope. I'm also able to jump to inherited classes or interfaces via a combination ofvim-gutentags,vim-laraveland the PHP language server. I get autocompletion of methods or classes via the same plugins.UltiSnipsprovides snippets so I can add new classes, tests or xml tags easily. Andvim-projectionistallows for auto-injecting text based on the folder I'm in, so a Laravel model or controller gets populated with all the boilerplate out of the box. I'm as fast (or faster) than a lot of my team in the editor, based on workflows I've been using over years with vim and tmux. In short: you can pry vim from my cold dead hands.However. VSCode and PHPStorm already have a lot of integrations built-in that I had to manually curate in my dotfiles. And installing new plugins are a couple of mouse clicks (or keystrokes) away, which are a lot easier to install than via
vim-plugor whatever.Vim as an IDE is a second-class citizen. I've built up my dotfiles over several (yes, 3, maybe more) years, across different languages and interests. And with every new language attempted comes the need to install more plugins to so that things work as expected. But I love building and tinkering with my vim workflow, so vim is for me.
If curating your dotfiles is a masochistic hobby and you enjoy the process, it's possible to get to IDE-level functionality with vim. But if you just need to get shit DONE (i.e. work), a preconfigured IDE is the way to go.
Also, here's how I got to near the same speed in VSCode that I have in vim (key combos to do different things):
ctrl + |ctrl + k, ctrl + |ctrl + 1…ctrl + nctrl + ~ctrl + taborctrl + shift + tabTry building a URL shortener. The basic concept is pretty simple—a user submits a long URL and is given a short URL that redirects to the user’s original URL.
If that is too easy for you, you can always track clicks to the short URL and provide analytics for how many users clicked it, time clicked, browser used, etc.
With 100k articles and a budget of 5k, I’d stick with WordPress! Let WordPress do what it’s good at.
For fun, though, and doing something I haven’t attempted yet, I’d entertain migrating posts to Contentful with a Gatsby frontend hosted on Netlify.
Quick aside: while I appreciate your boss wanting you to learn programming concepts such as conditionals, they don’t have much place in test code. Tests should be easily readable and self-documenting on what they are setting up, acting on, and asserting. Conditionals obfuscate the code under test—if you’re reaching for a conditional in a test you should break it into two tests
Honestly, because I didn't know it existed heheh. I guess the helper test method could be this instead, then (a nicely readable one-liner):
I'm open to using it, but want to mention for others reading this that the above may start to suffer from mystery guest; that is, a factory's valid attributes become so decoupled from the test verification logic, you can't figure out why things may be failing.
I tend to keep reusable methods in my tests to a minimum by default, as a way to combat hiding complexity in my apps. A good smell test for me is a long test--the longer the test (especially the test setup), the more likely the underlying class being tested is doing too much.
that said, the most my reusable methods ever do tend to deal with filling out valid parameters. here's an example:
in a test:
One thing I'd probably do is combine the month/date/year fields client-side and send over a 'date' field, just so you don't have to build / parse that in the controller. Same deal with the avatar, if it's possible I try to only send over exactly the fields I need so unsetting isn't needed. Honestly that's just nitpicking, on the whole everything looks pretty clean; some parts of the app (especially those dealing with user input) are just going to feel a bit gross.
I use RESTful routing conventions that come out of the box with Laravel's scaffolding. In your case, a password is part of either a
UserorAccountmodel. So there'd be an associatedUsersControllerorAccountsController, with a put/patch request toupdate(update being the name I'd use as the controller action).I originally got this convention from thoughtbot's Upcase, a monthly rails dev bootcamp-type deal.This post by Adam Wathan, "There's a Model Hiding in your Rest API, also really drives home the point that, if you're trying to shoehorn a "create" method in a controller that the "create" verb doesn't make sense in, it might mean you're missing something in your app's domain.
You're not getting closer yet, but I can see you're trying!
It isn't a question of weight w/ regards of SEO, it's a question of grouping. In the context of data, Posts shouldn't be grouped the same as Movies should be grouped. Movies have a different data structure that Posts or Pages just don't have: Year released, Genre, Director, Trailer, etc.
Movies (and Posts) are for similar content; Pages are for individual pages.
The thing is, Movies are not a post type within WordPress; so, the plugin Pods utilizes Custom Post Types to create a new Custom Post Type called Movies with the aforementioned data structure.
Note that yes, even with a Custom Post Type, you still need to fill in meta, title and page descriptions for each. This is indeed tedious, but it should be approached with the same care you took towards creating the blog post / whatever you are creating. Using the Yoast SEO plugin might help with crafting meta information that is better from an SEO standpoint.
I'm a fan of CF7—I didn't enjoy all of the bloat that Gravity Forms came with out of the box. CF7 is very basic, which fit my needs perfectly. Not to mention it's free :)
If you do end up going the CF7 route, I'd suggest CF7 Honeypot for simple spam protection, and Takayuki Miyoshi's other plugin, Flamingo, for managing the inbound messages that come through CF7 / simple CRM management.
It's a one-time $99 for as many local sites as you want, one production site. That $99 includes all minor version bumps, a major release is a new charge.
edit: info gotten from the laravel podcast, I'm not sure where/if that info is on the site
#4 is the best of the bunch by far! reason being, the categories are clearly delineated and easy to parse (different colors, etc). take from that what you will!