Warning
This is still progress and needs more testing.
A basic Laravel starter project for folks to get up and running with Laravel. There are many other ways to do this. I found DDEV to be the simplest.
DDEV is wonderful. I use it on all my WordPress too. Messing around with MAMP or using PHP, MySQL, Composer, and Apache with Homebrew is painful. DDEV makes running projects locally much easier. It uses Docker, but you don’t have to know Docker.
git clone https://github.com/srwild/laravel-starter.git
clone the repositorycd laravel-starter
enter the project directoryddev start
start DDEVddev composer install
install Composer packages.ddev artisan key:generate
generate the Laravel application key.npm install
install Node packages.npm run dev
compile the assets and start the Vite server that will refresh your browser when changes are saved.npm run build
will only compile the assets.ddev launch
launch the app in your browser or go tohttps://larvel-starter.ddev.site
. You should see the welcome page.
The purpose of this starter project is to get the SysAdmin work out of the way. There are more steps depending on what you want to use.
- This is setup with vanilla CSS and JavaScript. I leave it up to you if you want to use Sass (SCSS), Tailwind, or something else.
- You can also install Livewire, which is great.
- Inertia is another option if you want to use a frontend JavaScript like Vue or React. Note that you will need to adjust the file structure for that.
I setup the Vite server to use HTTPS. Safari won’t load the assets unless they are served over HTTPS, it throws CORS errors. The example .env
uses DDEV’s certs located in .ddev/traefik/certs
. Uncomment VITE_HTTPS_CERT
and VITE_HTTPS_KEY
in your .env
. If you don’t have anything in that directory, you may need to run ddev stop --all && mkcert -install
. This is part of installing DDEV on you machine, but is often missed.
If you have more issues or want to change them you can update the environment variables VITE_HTTPS_CERT
and VITE_HTTPS_KEY
. I’ve used mkcert, then I accidentally found DDEV creates its own. Cool.
If you’re working on the frontend, editing Blade and HTML, Laravel’s view caching gets really annoying and slows you down. Mashing refresh in the browser eventually works or running ddev artisan optimize:clear
. I have an option to disable caching completely in local environments by setting CACHE_DRIVER=array
and DISABLE_CACHE=true
. CAUTION: you will get Laravel errors occasionally, refreshing the page will solve it. There is most likely a better way to do this. If you know of one, please let me know.