Skip to content

Instantly share code, notes, and snippets.

View jorgemudry's full-sized avatar

Jorge Mudry jorgemudry

View GitHub Profile
@sebastiaanluca
sebastiaanluca / CarbonImmutableCaster.php
Last active March 24, 2024 14:39
Lazy Laravel Harvest API service
<?php
declare(strict_types=1);
namespace App\DataTransferObjects;
use Carbon\CarbonImmutable;
use Spatie\DataTransferObject\Caster;
class CarbonImmutableCaster implements Caster
@viezel
viezel / octane-on-forge.md
Last active December 16, 2023 21:57
Quickly get Octane running on Laravel Forge

Quickly get Octane running on Laravel Forge

  1. Spin up a new App server, choose PHP 8
  2. SSH into it and run sudo -i to become root
  3. Run pecl install swoole and enable what you need. (I disabled curl as it did not work for me)
  4. Add a new Site to your server and use git to pull in your Laravel project that has Octane installed.
  5. Point your DNS to your new site
  6. Enable SSL using Lets Encrypt
  7. Change your new Sites Nginx settings to (assuing your site is named octane.example.com):
@azagniotov
azagniotov / beautiful.rest.api.docs.in.markdown.md
Last active May 6, 2024 01:05
Example to create beautiful REST API docs in Markdown, inspired by Swagger API docs.
@lorisleiva
lorisleiva / toSqlWithBindings.php
Last active November 15, 2023 08:54
A little macro to get the SQL from a query builder without the annoying "?".
<?php
use Illuminate\Database\Eloquent\Builder;
Builder::macro('toSqlWithBindings', function () {
$bindings = array_map(
fn ($value) => is_numeric($value) ? $value : "'{$value}'",
$this->getBindings()
);
@meSingh
meSingh / JsonMiddleware.php
Last active July 11, 2022 09:19
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)
@lukevers
lukevers / LaravelInterviewQuestions.md
Created October 23, 2015 15:23
Laravel Interview Questions

Laravel 5 Interview Questions

This is a compiled list of Laravel interview questions. If Laravel is an engineer's PHP framework of choice, they definitely have potential to be a good candidate, but a lot of new PHP engineers have been into Laravel too. The framework itself is very welcoming to newcomers, which makes it easy for beginners to feel that they know more than they really do.

General Questions

1. How long have you been using Laravel?

This question can help decide what level of questions to ask.

@barryvdh
barryvdh / lumen_ide_helper.php
Last active April 10, 2023 10:26
Lumen IDE Helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel Lumen (5.1.1) (Laravel Components 5.1.*) on 2015-08-18.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
@ziadoz
ziadoz / CapsuleServiceProvider.php
Last active May 1, 2020 02:46
Laravel Eloquent/Capsule Silex Service Provicer
<?php
use Silex\Application;
use Silex\ServiceProviderInterface;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
use Illuminate\Cache\CacheManager;
class CapsuleServiceProvider implements ServiceProviderInterface
{
@fideloper
fideloper / install.sh
Last active October 30, 2023 20:03
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
Array
(
[0] => 1889883229
[1] => 488835183
[2] => 550593395
[3] => 763493425
[4] => 1932858889
[5] => 2095048392
[6] => 1762303890
[7] => 1408443226