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

New package - Nuxt Lighthouse Module

Implementing automated Lighthouse audits on each deploy of your Nuxt.js application.

New package - Storybook Directories

A simple module for generating your storybook story structure based on your directory structure.

Gitprefix - Automatically formatting commit messages

Git precommit hook for appending branch and emoji prefixes

Automated Pull Request Checks on Github

Using Probot to create automated checks on Github Pull Requests

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