From .dev to .test for development

Like most who use Valet (and many who don’t), I’ve been using the .dev TLD for projects on my development machine. And while I mostly use Firefox as my dev browser I do sometimes use Chrome. And Chrome no longers allows .dev to be used in this way (at least not without setting up HTTPS) – and who knows, perhaps Firefox will follow suit.

But the thing is, .dev is actually a valid TLD that’s owned by Google. We probably shouldn’t have been using it like that in the first place.

As this person (and others) have said, we really should be using one of the TLDs that are reserved for such things. My first thought was that I’d use .localhost for dev work and .test for testing, but .localhost may not work with VMs.

So I’m thinking I’ll just switch Valet to use .test, both for development and for testing, unless / until someone comes up with a better idea that works with VMs and both major browsers without needing to bother with HTTPS.

PS – I’m a hobbyist developer (my day job is in IT but not as a coder) so for me it’s simply not worth the hassle to set up certificates when I can simply type valet domain test in three seconds and then get back to coding. YMMV.

Advertisements
From .dev to .test for development

Napkin Theme for Bootstrap

I’m keen to find a ‘napkin’ theme for Twitter Bootstrap, for reasons outlined by Ken Arnold and Alex Lam. Basically I don’t want something to look finished when it isn’t.

The only one I’ve found so far is Bootswatch’s Sketchy … not sure if there are others, but if this one works then I probably won’t bother looking any further.

Napkin Theme for Bootstrap

Laravel $model->update() and $model->fill()

I just found Laravel’s $model->fill() and $query->update() on a couple of Stack Overflow posts.

The first operates on a model and takes an array (or perhaps a collection?) of updated values, and updates the model’s fields based on the values of the array. (I assume it does *not* automagically save the model – haven’t checked that yet.)

The second replaces get() in a query and updates the model (or models) returned by the query, without ever actually loading them (so without triggering saved or updated model events), and saves them in the database.

But it can also update just one model, eg:

$partner = Partner::find($partnerData['partner_id']);
$partner->update($partnerData);

They’re both described in the Laravel docs for Eloquent.

Laravel $model->update() and $model->fill()

Laravel Socialite driver not supported

I’m trying to get an existing Laravel 5.1 app to work with Okta authentication for my day job, using tequilarapido’s socialite-okta. But I’m getting errors. So I tried a simple proof-of-concept app, thus:

composer create-project laravel/laravel tequila-demo 5.1.*
cd tequila-demo
composer require tequilarapido/socialite-okta

…and then I did the socialite-okta setup:

# Added Tequilarapido service provider and Socialite alias to config/app.php
# Added 'okta' config to config/services.php and .env

…and finally I did the Laravel Social Auth setup:

# Added Socialite service provider to config/app.php
# Added redirectToProvider() and handleProviderCallback() to /app/Http/Controllers/Auth/AuthController.php
# Added auth/okta and auth/okta/callback routes to app/Http/routes.php

…but when I pointed the browser at http://tequila-demo.dev/auth/okta I got an error:

InvalidArgumentException in Manager.php line 90:
Driver [okta] not supported.

And I was stumped.

Then I found this issue which gave me the hint to add the following to the boot() function in app/Providers/AppServiceProvider.php (with some tweaking based on socialite-okta/src/SocialiteManager.php).

Socialite::extend('okta', function ($app) {
$config = $app['config']['services.okta'];
$provider = Socialite::buildProvider('Tequilarapido\Okta\OktaProvider', $config);
$provider->setOktaUrl($config['url']);
return $provider;
});

And lo and behold, once we set up the app in Okta and configured everything in the .env file, it works perfectly.

You can re-live the excitement in the commit history of the git repository, if you’ve a mind to do so.

Laravel Socialite driver not supported

New Laravel app

Note – this post is a quick reminder for myself on the steps needed to get a new Laravel app up and running quickly on my Mac dev box, which has Valet set up on my Code directory.

If this post helps someone else, that’s great – but it is not intended for anyone else but me.

  1. In the Terminal window, do cd Code and then laravel new foobar to create the project
  2. Wait while Composer does its thing, downloading and installing a ton of stuff
  3. Type cd foobar to go in to the new project’s directory
  4. Then do git init and git add . and git commit -m "initial commit" to set up the Git repo
  5. In MySQLWorkbench, open Local Mac and create a new schema named foobar with default collation set to utf8-default collation
  6. In the .env file (Not the .env.example file) set APP_NAME = Foobar and DB_DATABASE=foobar and then copy the username and password from another working project.
  7. Back in the Terminal, do artisan migrate and you’re done.
New Laravel app

Raspberry Pi DLNA

I’ve got DNLA working on my Pi, but the minidlna service isn’t starting at boot.

I’ve been typing the command sudo service minidlna restart after each reboot, but I don’t want to have to remember to do that every time the Pi restarts for some reason. Typing sudo service minidlna force-reload is also helpful when you’ve added a new file to the server and want it to be available. Perhaps I’ll stick that in a regular cron job or something.

I found this page which suggested that I sudo apt-get install rcconf and sudo rcconf but rcconf said that the minidlna service is already set to run on startup … which isn’t happening. Every time I reboot, sudo service --status-all says minidlna isn’t running (and, more importantly, I can’t connect from VLC).

I’ve added service minidlna restart to /etc/rc.local but the service still doesn’t start on boot. And when I did update-rc.d sudo service minidlna restart it said using dependency based boot sequencing … which I don’t really understand but it seems to suggest that this ain’t going to work. 🙂

Which is weird, because sudo /etc/init.d/minidlna start works fine to start the service.

So Plan B was to do sudo crontab -e and stick @reboot service minidlna restart in it … still no dice.

I’ll take another look in the morning…

[Edit] This page suggests that update-rc.d minidlna defaults (or perhaps sudo update-rc.d minidlna defaults) might work … so I’ve done that. Let’s see if miniDLNA comes back after the next reboot.

Raspberry Pi DLNA

Cannot Remove ondrej-php

Sometimes when trying to do a vagrant provision I get an error message cannot remove '/etc/apt/sources.list.d/ondrej-php-*'

When this happens, I need to comment out the line config.vm.provision :shell, :inline => "sudo rm /etc/apt/sources.list.d/ondrej-php-*" in C:\Vagrant\[my-vagrant-box]\scripts\homestead.rb (by putting a # in front of it), then run vagrant provision, then un-comment that line again.

Cannot Remove ondrej-php