Skip to content

Instantly share code, notes, and snippets.

@merciof
merciof / index.php
Created August 17, 2021 23:09
Headers to prevent CORS errors.
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: *");
// header('Access-Control-Allow-Credentials: true');
// header('Access-Control-Max-Age: 86400'); // cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
@merciof
merciof / AbstractApi.php
Last active July 10, 2021 13:29
Trait para a REST API do sebo-rural no CakePHP. Atende CRUD para as entidades Course, Book, Student e Genre.
<?php
declare(strict_types=1);
namespace App\Controller;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Datasource\ResultSetInterface;
use Cake\ORM\Table;
@merciof
merciof / endereco-form.php
Last active November 30, 2020 21:53
Consumo de webservice viacep com jquery
<html>
<head></head>
<body>
<form action="">
<input type="text" name="cep" placeholder="cep">
<input type="text" name="rua" placeholder="rua">
<input type="text" name="numero" placeholder="numero">
@merciof
merciof / Procfile
Last active August 14, 2020 20:09
Procfile para implantação de app CakePHP 3 no Heroku em servidor apache2
web: vendor/bin/heroku-php-apache2 webroot/