Skip to content

Instantly share code, notes, and snippets.

@markjaquith
Created July 20, 2023 21:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markjaquith/dcb0c32cf670ae22d1c96a608bff1672 to your computer and use it in GitHub Desktop.
Save markjaquith/dcb0c32cf670ae22d1c96a608bff1672 to your computer and use it in GitHub Desktop.
Rough notes from Laracon US 2023

These notes are super rough, and I didn’t take notes for a couple sessions. Let me know if you found them useful or they helped you remember things presented at the conference! @markjaquith on Twitter.

Pest PHP

by Nuno Maduro

[!question] How do snapshots work in CI? Won’t there not be an existing snapshot when the tests run?

Cool new features

  • Expect globals not to be called.
  • Architectural tests seem really useful.
  • Force classes in a folder to extent a certain class.
  • Type coverage is new in 2.9.
  • Drift plugin to convert from PHPUnit.

How to get unstuck

by Joel Clermont @jclermont

Problem solving techniques

  • Simplify the problem
  • Eliminate layers of abstraction
  • Rubber ducking

Laravel in the Enterprise

by Matt Stauffer

[!quote] Software design is not about minimizing design complexity, but rather spending our complexity budget where it can do the most good.

— Kent Beck

Stick to conventions when developing enterprise software.

You need to test your code, but you also need to test that your code works with the other systems it touches.

Build your own thin abstractions in front of any external service, even if they have an SDK.

Build local seeders that can build the database in different states. Better than giving people a production database dump.

Tech debt management is real work.

From developer to founder

by Ben Orenstein @r00k

The Development Abstraction Layer by Joel

Don’t start with SASS, start by “selling” something free.

It’s useful to become “the X guy”.

Next, sell a one-time purchase. Info products are great.

[!question] What could I write a course on?

Next, sell something with built-in distribution.

The Stair Step Method by Rob Walling

Warning

Don’t pick a bad idea.

Developers are highly likely to pick a bad idea. We have skewed perspectives.

[!idea] It’s like X, but sucks less.

[!idea] Look at what you built internally at work.

[!quote] Good idea generator: 1. Have any idea 2. Pursue it 3. Build something that makes it easier to achieve 4. #3 is your good idea — Matt Wensing

Individual people are horrible customers. Sell to businesses.

It’s a mistake to assume that competitors own the market. That’s now how it works. Competitors mean that the idea has merit.

People will literally opt for products based on vibes. It can be something really small that tips the scales.

[!idea] Look for dissatisfaction among competitors. See what is bad about their products.

Read: The Mom Test.

[!idea] Sell a product that does not exist yet.

Choose customers you like. i.e. not used car salesmen or real estate agents.

Niche down… get really specific.

Collect e-mails. Get that page up and get their e-mail address.

Think like a business when deciding your prices. Businesses that you want to have as customers won’t sneeze at eye-watering prices.

Watch people sign up. You will learn a lot.

Important

Don’t build any feature you weren’t asked for.

Ignore any advice that is intended for VC-funded companies.

Don’t worry about taxes or regulations at the start. These mistakes won’t kill your business.

Important

Don’t go alone. Get a co-founder.

Find peers who are also running similar businesses.

Testing with Fakes

by Jason McCreary

Use Http::preventStrayRequests(), so it throws an exception if you fire off a request that has not been faked.

Use $this->mock()

Use realtime facades by prefixing Facades\ to the import. Then you can call methods statically.

And that allows you to do SomeClass::expects(), which you should use, because it mocks and verifies.

Livewire v3

by Caleb Porzio

Don’t need to include Alpine or the main Alpine plugins, because Alpine is baked in.

Won’t have to use wire:key (or at least as much) because of better diffing.

Network requests are bundled together.

All-new documentation and website (looks nice).

wire:navigate added to links will make them load in an SPA mode.

.prevent is the default for wire:submit

wire:model.defer is now the default

let $wire = Livewire.first()

If that component has a title attribute, $wire.title can then be assigned to or read from.

$wire.save() would save it and call the backend function.

Since wire:model is just alpine, under the hood, you can do x-model to do two-way binding.

$this->js(<<<‘JS’
	alert(“foo”);
JS);

And you can add your own macros like $this->modal()

You can use PHP attributes like #[Locked] to change attributes.

Make your own via artisan livewire:attribute

Can hook into the lifecycle of the property. mount, update

#[Url(as: ‘foo’)] Binds a variable to the URL query string

#[Rule(‘required|min:3’)]

wire:model.blur

FormObject abstracts form fields into a single object to clean up your form components.

#[Reactive] to make child components reactive.

Access parent with $parent

Make child components lazy with lazy attribute.

Define placeholder() to render a placeholder.

Streaming responses. wire:stream using $this->stream(‘thing’, $partial);

Wiretap is dev tools for Livewire.

Cmd-K to show/hide.

Includes live reloading and time travel.

Laravel Data

by Freek Van der Herten

Creates data objects. You get typing. Rule validation with #[Rule] (or things like #[Email])

artisan typescript:transform

It will scan your app for data objects and generate TypeScript definitions. Really nice.

#[DataCollactionOf(SomeOtherDataClass::class)] for nested data objects.

State Machines

by Jake Bennett

Refacturing Guru has resources about code patterns.

Create a base state class with transitions as methods that throw exceptions.

Create classes for each state.

Methods on each state for transitions you want to handle.

state() method for getting the current state object, given an object.

NativePHP

by Marcel Pociot

Looks amazing. Can think of a bunch of uses for this. Electron + Laravel + PHP and creates native apps for Mac, Windows, Linux.

Laravel Validation

by Tim MacDonald

Validation shouldn’t be too early, nor too late. It should happen precisely when it is needed.

Validation should be part of the process, not a distinct step.

Your validation should be consistent between the frontend and the backend.

Messaging should be consistent and actionable.

It should allow for quick and obvious iteration.

User input should be forgiving.

Shift from scolding errors to guiding users to success. Show success messages as they complete each field correctly. It makes them feel good.

Don’t use placeholders as help text.

Track, analyze, and act on validation errors (oof, that one is hard advice to follow).

Publishing your work

by Aaron Francis

[!quote] Publishing your work increases your luck — Aaron Francis

Luck

Ways that luck manifests:

  • Job offers
  • Open source success
  • Friends
  • Interviews

These things are outside of your direct control.

Working publicly builds a body of work that speaks better than any resume.

Work

[!idea] A series called “I tried something” where I just play with tech and share my thoughts.

Don’t play it cool. You’re not that cool. You need to be passionate and curious.

You have hidden expertise. Share it with the world, and opportunities will find you.

People don’t know the things you know.

How do I get started? Just do it. It’ll be terrible, and that’s fine. Nothing will ever be perfect.

Publishing

Publishing could be Twitter, blog posts, YouTube videos.

You can become really bitter, thinking about why good things are happening to other people and not to you.

Two paths forward:

  1. Give in to the fear — protect your ego and don’t put yourself out there. Die with regret.
  2. Push past the fear — start sharing everything you do, and watch the world open up for you.

You will have setbacks. Keep going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment