Skip to content

Instantly share code, notes, and snippets.

Avatar

Thiago Marini thiagomarini

View GitHub Profile
@thiagomarini
thiagomarini / index.php
Last active Feb 18, 2019
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.
View index.php
<?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 Jan 4, 2019
Handling SQS events example
View bref.php
<?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 Dec 6, 2018
Weengs Pre Spaghetti Exaplme
View pre_spaghetti.php
<?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'] : '';
View weengs_data_fecher.php
<?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 Dec 20, 2018
Service Usage in Controller Example
View laravel_service_usage_controller.php
<?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 Dec 20, 2018
Weengs Service Response Example
View service_response_example.php
<?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 Dec 20, 2018
Weengs Service Request Example
View service_request_example.php
<?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 Dec 20, 2018
Weengs Service Example
View service_example.php
<?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;
View laravel_spaguetti_controller.php
<?php
/**
* Create new shipment barcode
*
* $param Request $request
* @return void
**/
public function createShipmentBarcode(Request $request)
{
// validate required fields
@thiagomarini
thiagomarini / readme.sh
Created Oct 29, 2018
How to install supervisor on Amazon Linux
View readme.sh
# 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