Skip to content

Instantly share code, notes, and snippets.

View thiagomarini's full-sized avatar

Thiago Marini thiagomarini

View GitHub Profile
@thiagomarini
thiagomarini / index.php
Last active August 7, 2021 16:34
Plain PHP Curl proxy script example for json APIs. I tried using Apache mod_proxy for that but it was returning 301 only on curl, on guzzle it was fine.
<?php
// Needs to be used with a .htaccess file pointing all requests to it
$uri = $_SERVER['REQUEST_URI'];
$queryString = http_build_query($_GET);
$payload = file_get_contents('php://input');
$url = 'https://foo.bar' . $uri;
@thiagomarini
thiagomarini / bref.php
Last active January 4, 2019 15:07
Handling SQS events example
<?php
define('LARAVEL_START', microtime(true));
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
// Laravel does not create that directory automatically so we have to create it
// You can remove this if you do not use views in your application (e.g. for an API)
@thiagomarini
thiagomarini / pre_spaghetti.php
Created December 6, 2018 10:48
Weengs Pre Spaghetti Exaplme
<?php
// include environment related files
include_once '../inc/env.inc.php';
// will return JSON response
header('Content-type: application/json');
WEApplication::serviceAvailabilityCheck();
$secretDev = isset($_POST['secret_dev']) ? $_POST['secret_dev'] : '';
@thiagomarini
thiagomarini / weengs_data_fecher.php
Created December 6, 2018 09:11
Data Fetcher Example
<?php
namespace Weengs\DataFetcher\Collections\Admin;
use Weengs\DataFetcher\DataFetcherInterface;
use Weengs\Models\WmsUser\App;
class ListApps implements DataFetcherInterface
{
/**
@thiagomarini
thiagomarini / laravel_service_usage_controller.php
Last active December 20, 2018 12:23
Service Usage in Controller Example
<?php
/**
* Requests a call from the sales team
*
* @method PUT
* @param Request $request
* @param int $userId
* @param RequestPhoneCall\Service $requestCall
*
@thiagomarini
thiagomarini / service_response_example.php
Last active December 20, 2018 12:15
Weengs Service Response Example
<?php
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall;
use Weengs\Models\User\User;
use Weengs\Services\Common\BaseServiceResponse;
class Response extends BaseServiceResponse
{
/**
@thiagomarini
thiagomarini / service_request_example.php
Last active December 20, 2018 12:16
Weengs Service Request Example
<?php
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall;
use Weengs\Exceptions\ValidationException;
use Weengs\Services\Common\BaseServiceRequest;
class Request extends BaseServiceRequest
{
/**
@thiagomarini
thiagomarini / service_example.php
Last active December 20, 2018 12:22
Weengs Service Example
<?php
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall;
use Weengs\Exceptions\BusinessException;
use Weengs\Models\User\Onboarding;
use Weengs\Models\User\User;
use Weengs\Services\Common\BaseService;
use Weengs\Services\Common\RequestInterface;
use Weengs\Services\Common\ResponseInterface;
@thiagomarini
thiagomarini / laravel_spaguetti_controller.php
Last active December 6, 2018 08:30
Laravel Spaghetti Example
<?php
/**
* Create new shipment barcode
*
* $param Request $request
* @return void
**/
public function createShipmentBarcode(Request $request)
{
// validate required fields
@thiagomarini
thiagomarini / readme.sh
Created October 29, 2018 16:10
How to install supervisor on Amazon Linux
# Install it as a yum package instead of throgh pip (will save you from lots of hassle)
# first get epel
sudo amazon-linux-extras install epel
# then install supervisor
sudo yum install supervisor