Serving static content in Laravel Valet


A couple of weeks ago I was working on a very non-conventional project where I had to create a bunch of UI components in standard php files like back in the day. My local server of choice is laravel/valet which tries to automatically handle url resolution for frameworks.

However when accessing php files directly, by default it tries to route every request through an index.php entry point so that frameworks and general url rewriting works. So for example I have a directory with various template files such as about.php which pull in standard components to build up the template, but I can’t access this file on the frontend as it just requests the index.php file while the url is requesting about.php.

Not ideal.

The great thing about Laravel Valet however, is that you can create custom drivers that should run depending on the logic you provide. To enable the functionality I wanted, I created a static valet driver. The driver simply looks for a static file in the root of the project and runs. Easy.

Instructions on how to use the driver are included in the readme. Please share and star ⭐️ the project if you found it helpful.

Related Posts

Netsells 💙 Vue (+ Vue.js London)

Why we at Netsells love the Vue.js framework and where you can find us later this week

Maximising Productivity with Slack

Staying productive with your favourite workplace chat app

Stop with the unhelpful loading spinners

Give some context to your users with some helpful loading text

Responsive Blocks and Vertical Alignment

How to create responsive cross-browser blocks with vertically aligned content

Development Goals for 2018

New Year Promise.resolve()

Progressively Infiltrating Google

Attending the Google Academy for a course on Progressive Web Apps

Laravel Certification Prelude

The Laravel Certification exam is here and I'm taking it.

Helpful Laravel Valet aliases

Valet up, up, down, down, left, right, left, right, B, A.

Aligning content in a grid using Vue

A Vue plugin to ensure grid content pleases the eye.

Validating payment details in Vue

A simple Vue plugin to validate card details