Laravel POST requests with Guzzle
Feb 082016First, set the right namespace to use.
1
use GuzzleHttp\Client;
Then, create a new GuzzleHttp instance:
First, set the right namespace to use.
1
use GuzzleHttp\Client;
Then, create a new GuzzleHttp instance:
Step 1 — Install Postfix
In this step, you'll learn how to install Postfix. The most efficient way to install Postfix and other programs needed for testing email is to install the mailutils package by typing:
sudo apt-get install mailutils
Press ENTER to install them. Near the end of the installation process, you will be presented with a window that looks exactly like the one in the image below. The default option is Internet Site. That's the recommended option for this tutorial, so press TAB, then ENTER.
After that, you'll get another window just like the one in this next image. The System mail name should be the same as the name you assigned to the Droplet when you were creating it. If it shows a subdomain like mars.example.com, change it to just example.com. When you're done, Press TAB, then ENTER.
Step 2 — Configure Postfix
Change the line that reads inet_interfaces = all to inet_interfaces = loopback-only. When you're done, that same section of the file should now read:
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
sudo service postfix restart
Если в консоли периодически проскакивает
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
или
sh: 0: getcwd() failed: No such file or directory
то просто нужно выйти из папки, которую до этого удалили.
A brand new feature in Laravel 5 is an Artisan scheduler. This is designed to simplify tasks that need to be scheduled. All that is required is setting up one cron job that calls php artisan schedule:run and have it run every minute.
Once your cron is setup you can schedule any task to run in a concise and friendly manner. It takes the pain out of having to remember cron scheduling and is really simple. These schedules are created inside your “app/Console//Kernel.php” file.
Here is an example of a fictional task to clear the cache every hour:
$schedule->command('cache:clear')
->hourly()
->sendOutputTo($filePath)
->emailOutputTo('john@doe.com');
It doesn’t end there. You can also call class methods:
$schedule->call('SomeClass@method')->dailyAt('10:00');
Or use a closure:
$schedule->call(function(){
//..
})->everyThirtyMinutes();
And even terminal commands:
$schedule->terminal('gulp task')->fridays()->when(function(){
return true;
});
Laravel has always had developers in mind when creating new features and this one is no different. Take a look at the different scheduling methods available:
->hourly()
->daily()
->at($time) // 24 hour time
->dailyAt($time)
->twiceDaily()
->weekdays()
->mondays()
->tuesdays()
->wednesdays()
->thursdays()
->fridays()
->saturdays()
->sundays()
->weekly()
->weeklyOn($day, $time)
->monthly()
->yearly()
->everyFiveMinutes()
->everyTenMinutes()
->everyThirtyMinutes()
->days() // Days of the week.
I love the syntax and there is even more which you can find in this file. If you want to dig deeper checkout everything new in Laravel 5
This is another feature that is aimed at increasing your developer happiness. I think you’ll enjoy it and it will bring a lot of power to your apps.
location /tv/ {
rewrite /tv/([a-zA-Z0-9_\-]*)/([0-9]*)/(.*)/(.*)$ /hls/$3/$4?secl=$1§=$2;
}
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time status $status bytes $body_bytes_sent';
#Uncomment to debug rewrite rules
#rewrite_log on;
server {
listen 80;
server_name test1.com;
access_log logs/test1.access.log main;
#Uncomment to debug rewrite rules
#error_log logs/rewrite.log notice;
root /usr/local/test1;
index index.php;
# WORDFENCE FALCON ENGINE CODE
#Match on gzip first because ordering matters.
location ~ "/site/wp-content/wfcache/.*gzip$" {
gzip off;
types {}
default_type text/html;
add_header Vary "Accept-Encoding, Cookie";
add_header Content-Encoding gzip;
}
#If the previous matched, the following location won't be executed.
location ~ /site/wp-content/wfcache/.* {
add_header Vary "Accept-Encoding, Cookie";
}
set $wordfenceCacheOn 1;
#Don't cache form submissions.
if ($request_method = POST) {
set $wordfenceCacheOn 0;
}
#Allow caching of /?123=123 because this is a common DDoS to override caches.
if ($query_string !~ "^(?:\d+=\d+)?$") {
set $wordfenceCacheOn 0;
}
#Only cache URL's ending in /
if ($request_uri !~ \/$) {
set $wordfenceCacheOn 0;
}
#Don't cache any cookies with this in their names e.g. users who are logged in.
if ($http_cookie ~* "(comment_author|wp\-postpass|wf_logout|wordpress_logged_in|wptouch_switch_toggle|wpmp_switcher)") {
set $wordfenceCacheOn 0;
}
set $wordfenceEncoding "";
#Oh, you want gzipped content?
if ($http_accept_encoding ~ gzip) {
set $wordfenceEncoding _gzip;
}
set $wordfenceHTTPS "";
if ($scheme = 'https'){
#If you want to ENABLE HTTPS caching, comment out the next line.
set $wordfenceCacheOn 0; #Comment this line out to enable HTTPS caching.
set $wordfenceHTTPS '_https'; #Uncomment this line to enable HTTPS caching.
}
#The main purpose of this line is to capture the URL components into variables.
if ($request_uri !~ "^\/*(?<wfone>[^\/]*)\/*(?<wftwo>[^\/]*)\/*(?<wfthree>[^\/]*)\/*(?<wffour>[^\/]*)\/*(?<wffive>[^\/]*)(?<wfsix>.*)$"){
set $wordfenceCacheOn 0;
}
#If the file doesn't exist then don't serve from cache.
if (!-f "$document_root/site/wp-content/wfcache/${http_host}_${wfone}/${wftwo}~${wfthree}~${wffour}~${wffive}~${wfsix}_wfcache${wordfenceHTTPS}.html${wordfenceEncoding}") {
set $wordfenceCacheOn 0;
}
if ($wordfenceCacheOn = 1) {
rewrite .* "/site/wp-content/wfcache/${http_host}_${wfone}/${wftwo}~${wfthree}~${wffour}~${wffive}~${wfsix}_wfcache${wordfenceHTTPS}.html${wordfenceEncoding}" last;
}
# END Wordfence Rules
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ .php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
}