Categories
Laravel

Laravel Sessions Gotcha

Lost a lot of time debugging missing values in the Session. They were set in a controller method which I then dd().

Killing the process seems to stop the value being saved in the session. It showed up in that method, but the request didn’t complete so the value was missing from subsequent requests.

Upshot: Let the request complete without dd() to save sesssion values.

 

Categories
JavaScript Laravel

Laravel Elixir Notes

gulp –production minifes and removes console.log which may not be what you want! Especially when debugging the process.

 

Categories
Servers

Add Lets Encrypt Domain

cd /opt/certbot

./certbot-auto certonly --webroot -w /var/www/html \
-d tutorial.serverops.io \
--non-interactive --agree-tos --email me@example.com
Categories
Laravel

Laravel Windows Devs Gotchas

Homestead is slow. Native OS is fast but watch out for these issues.

  • Probably no Redis. Tagged caching not possible with file system
  • Storage facade by default writes to storage/ and uses a symlink for public files from the /public dir. Windows doesn’t have symlinks. (Could probably fix with environment config files)
Categories
PHP

Installing PHPUnit

Download latest version

  1. Saved .phar in c:\server\bin
  2. Add c:\server\bin to PATH
  3. Follow their instructions for creating  a .cmd wrapper
  4. Test by calling phpunit –version from cmd

Not sure how Laravel connects its tests/ to phpunit yet. Also not sure if version mismatch between Laravel and latest matters.

Categories
Laravel

Monitor Laravel SQL Queries

DB::listen(function($sql) {
    var_dump($sql->sql);
});

Categories
PHP

PHP7 Windows OpenSSL

I just upgraded from PHP 5.6.20 to 7.0.13 on Windows 10.

The existing Apache 2.4 installation uses Open SSL DLLs incompatible with PHP7.

I copied these two files from php7 to apache/bin

  • libeay32.dll
  • ssleay32.dll

Seems to be working now

Categories
Servers

Uploading to AWS S3

101 Demo

[code]
<?php
// Instantiate an Amazon S3 client.
$s3 = new S3Client([
‘version’ => ‘latest’,
‘region’ => ‘ap-southeast-2’,  //Sydney
‘scheme’ => ‘http’, //omit, or https on servers that support it
‘credentials’ => [
‘key’ => ‘ YOUR KEY ‘,
‘secret’ => ‘ YOUR SECRET ‘
]
]);

// Upload a publicly accessible file. The file size and type are determined by the SDK.
try {
$s3->putObject([
‘Bucket’ => ‘yourbucket’,
‘Key’ => ‘path/to/key.png’,
‘Body’ => fopen(‘my-picture.png’, ‘r’),
‘ACL’ => ‘public-read’,
]);

echo "<p>Picture uploaded [tick]</p>";

} catch (Aws\Exception\S3Exception $e) {
echo "There was an error uploading the file.\n";
}
?>

[/code]

Categories
Servers

Ubuntu Memory Usage

[code]
ps aux –sort -rss | head -n10
[/code]

Categories
Uncategorized

SSH into Vagrant Homestead

Putty Gen, convert Homestead\.vagrant\machines\default\virtualbox\private_key to .ppk for Putty to use.

username is vagrant.