Skip to content

Instantly share code, notes, and snippets.

Install PHP 8.1, node 16 and Docker in Ubuntu.

These scripts can be run with the following commands, by a super user. This installs a lot of stuff, read first.

You can add -s -- --dry-run to then end to do a dry run first.

These are tested on an ec2 instance running vscode remote

Usage

@Shelob9
Shelob9 / NewFile.php
Last active August 10, 2022 21:13
Call one artisan command, from another command, echo or stream its output
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
class Name extends Command
{
protected $signature = 'something';
protected $description = 'Calls other commands';
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue2'
export default defineConfig({
plugins: [
laravel([
'resources/js/app.js',
]),
vue({
@Shelob9
Shelob9 / vite.config.js
Created July 22, 2022 16:18
Code for Laravel vite React fast refresh with tailwind https://twitter.com/Josh412/status/1547628986695446530
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: 'resources/js/app.jsx',
refresh: [
'resources/js/app.jsx',
'front-end-client/src/**',
'resources/components/react.blade.php',
<?php
trait HandlesContentType {
protected function getContentType(string $name) : string
{
return match($name){
Str::endsWith($name, '.css') => 'text/css',
Str::endsWith($name, '.js') => 'text/javascript',
Str::endsWith($name, '.html') => 'text/html',
default => 'text/plain',
@Shelob9
Shelob9 / click-test.js
Created July 14, 2022 15:57
Test clicks and if elment is or is not in the document after clicking with React @testing-library/react
import "@testing-library/jest-dom";
import { render, act, screen } from "@testing-library/react";
import Accordian from './Accordian';
describe("Accordion", () => {
it("opens", () => {
const { getByText } = render(
<Accordion question="Question" answer="Answer" />
);
act(() => {
import './bootstrap';
import '../css/app.css';
import React from 'react';
import { render } from 'react-dom';
import { createInertiaApp } from '@inertiajs/inertia-react';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
const defaultTheme = require('tailwindcss/defaultTheme');
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
'./resources/js/**/*.jsx',
//NEW - Check tsx files for tailwind styles
<?php
class SomeCommand extends Command {
public function info($message){
logger()->info($message);
parent::info($message);
}
}
<?php
namespace App\Http\Controllers;
use App\Services\PmIdentityService;
use Aws\S3\S3Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
use InvalidArgumentException;