This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function forceCSVFileDownload($filename, $csv) { | |
header('Content-Disposition: attachment; filename="'.$filename.'"'); | |
header('Content-Type: csv/plain'); # Don't use application/force-download - it's not a real MIME type, and the Content-Disposition header is sufficient | |
header('Content-Length: ' . strlen($csv)); | |
header('Connection: close'); | |
print($csv); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function str_putcsv($input, $delimiter = ',', $enclosure = '"') { | |
// Open a memory "file" for read/write... | |
$fp = fopen('php://temp', 'r+'); | |
// ... write the $input array to the "file" using fputcsv()... | |
foreach ($input as $fields) { | |
fputcsv($fp, $fields, $delimiter, $enclosure); | |
} | |
// ... rewind the "file" so we can read what we just wrote... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Path\To\Behaviors; | |
use System\Classes\ModelBehavior; | |
/** | |
* Model behavior that allows to store some model's attributes | |
* in json format in grouping fields in db. | |
* | |
* USAGE: In your model add | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/ | |
/* | |
The MIT License (MIT) | |
Copyright (c) 2015 | |
Permission is hereby granted, free of charge, to any person obtaining a copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function runCommand () | |
{ | |
$command = 'php artisan queue:listen > /dev/null & echo $!'; | |
$number = exec($command); | |
file_put_contents(__DIR__ . '/queue.pid', $number); | |
} | |
if (file_exists(__DIR__ . '/queue.pid')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CountryCodes | |
{ | |
private static $codes = array ( | |
'AF' => 'Afghanistan', | |
'AX' => 'Åland Islands', | |
'AL' => 'Albania', | |
'DZ' => 'Algeria', | |
'AS' => 'American Samoa', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo chown -R www-data:www-data * | |
sudo find . -type d -exec chmod 755 {} \; | |
sudo find . -type f -exec chmod 664 {} \; | |
sudo chmod -R g+s storage themes | |
sudo chmod -R ug+rwx storage themes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Backend\Classes\Controller; | |
use Illuminate\Http\Response; | |
class ApiController extends Controller { | |
protected $statusCode = Response::HTTP_OK; | |
public function setStatusCode($code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return PhpCsFixer\Config::create() | |
->setRules([ | |
'@PSR2' => true, | |
'array_syntax' => ['syntax' => 'short'], | |
'combine_consecutive_unsets' => true, | |
'method_separation' => true, | |
'no_multiline_whitespace_before_semicolons' => true, | |
'single_quote' => true, |
OlderNewer