Fixing ReflectionException: Class scope does not exist in file when setting up Laravel Passport Scopes

Problem: I’m retro-fitting ‘scopes’ to an existing Laravel Passport API to allow some different levels of client access. After adding the available scopes with Passport::tokensCan, and default scopes with Passport::setDefaultScope, and attempting to specify a scope on a route like so:

Passport::setDefaultScope([
    'other-access'
]);

Passport::tokensCan([
    'write-access' => 'Read-write access',
    'read-access' => 'Read-only access',
    'other-access' => 'Other access'
]);
Route::get('endpoint/count', 'API\EndpointController@count')->middleware(['auth:api', 'scope:read-access']);

And an attempt to query the route gives this error:

ReflectionException: Class scope does not exist in file /path/to/webroot/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 790

Solution: READ THE DOCS. Again, I didn’t read the docs FULLY. In order to use token scopes, the docs say…

To get started, add the following middleware to the $routeMiddleware property of your app/Http/Kernel.php file:

'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,

🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️

135 Film DX recoding solution

Problem: I own a Pentax P30t Film SLR which only allows ISO to be set via DX encoding on the film canister. If no DX code is present, the ISO defaults to 100.

Solution: There are all sorts of existing solutions involving tin-foil, stickers or scratching the canister but I wanted a more permanent re-usable solution and came up with this ‘shim’ idea.

The method is as follows, with simple explanation in the captions where needed:

0.4mm aluminium sheet
0.4mm aluminium sheet from a local hobby store
Measuring the canister
Measuring the canister
Sheet cut to size
Sheet cut to size, and edges filed nice and smooth / safe
Checking sheet for canister width fit
Checking sheet for canister width fit
Preparing to roll the sheet
Preparing to roll the sheet, note the socket I chose as a former is smaller than the canister 
Sheet taped to former
Sheet taped to former before rolling
Shim cut to length
Shim cut to length
Text fitting shim
Text fitting shim, it should ‘click’ into place nicely.
Marking out the DX block positions
Marking out the DX block positions

 

Code added and 2nd test fit
Code added with PVC tape and second test fitting
In-camera test
In-camera test, is JUST fits. Slightly thinner sheet would be better

Additional notes: 

  • 0.4mm aluminium sheet was the thinnest they had in my local hobby store. I plan on trying .3mm sometime soon.
  • Choice of tape matters. Good quality soft PVC tape can be punctured by the pins in the camera, and is also quite thick. Cheap electrical tape is probably better. Best would be to block-out the code with etch-primer and a suitable hard shell paint I think. Future version
  • The length of the piece of aluminium’s important as you want it to butt-up to the inside corner to prevent the shim rotating when the film is inserted.
  • Choice of former, in my case a socket, is a bit hit and miss. You want to over curl it and let it spring back to the final size.
  • I taped the sheet to the former before rolling with duck-tape.

Testing the shim:
For a camera like the P30t, there’s no way to read-back or verify which ISO value has been set by a DX code. i.e there’s no LCD display. So to check that the shim is working:

  1. Insert a factory canister with a DX code on it that differs from the one on the shim and take a light meter reading against a constant light source. A PC/Laptop screen showing a white background is a good one. Note the reading.
  2. Add the shim to the canister, and take another reading, noting it.
  3. Compare the readings with what you’d expect to see.
    For example let’s say the factory canister has a 100 ISO DX code on it, and the reading is 1/60th at ƒ8. If the shim has a 400 ISO code on it, you would expect there to be a difference of 2 stops in the reading. So 1/250th at ƒ8 or 1/60th at ƒ16.

This process inspired me to design a t-shirt, and ended up in a very tiny t-shirt collection on Teespring: https://35mmtees.uk

DX Encoding chart t-shirt

If you have questions, corrections or criticisms please leave a comment below. Or just let me know what you thought with a click/tap on a thumb: Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Adding sections or headings to WordPress Menus – Making use of the walker_nav_menu_start_el filter

The WordPress menu builder makes it easy to add nested menu item links to a named menu, and display it in pre-defined theme location. However, as of writing in Jan 2019, there’s not an easy or built-in way to add menu sections or section headers. Here’s my solution:

The Design

Example visual to be recreated as a WordPress menu
Example visual to be recreated as a WordPress menu

The adjacent image shows the design that I’ve been asked to translate to a WordPress native menu. The orange items are page links. The white items are section headers and should not be active in any way. They are simply visual cues to aid navigation.

The Challenge

‘Out of the box’ WordPress doesn’t provide a place for menu section headers like ‘Services’ and ‘Products’ to be entered. It is possible to add them based on a menu item’s class or ID using the CSS ‘content‘ property, or an absolutely positioned image, but this is tacky and hard-coded, so site owners and admins can’t easily change the menu section headers without a developer type person or some Additional CSS hackery.

We need to find a way of adding section headers that uses the WordPress menu builder and remains editable. Continue reading “Adding sections or headings to WordPress Menus – Making use of the walker_nav_menu_start_el filter”

Remove all account data, stored mail and attachments from Postbox app (Mac OS)

The problem with stored Postbox data

I use Postbox, the Mail Client as a tool for checking problems with customer’s email accounts, and migrating mail data. When I have finished using it I don’t want to retain their data, nor do I want it taking up space on my machine. Just removing the ‘accounts’ doesn’t actually remove the data, it sits in Application Data forever (well maybe not forever, but a long time).

The solution might be user profiles

While searching for the location of stored mail data, I chanced across the Postbox Profile Manager. This allows complete profiles to be added and removed. Continue reading “Remove all account data, stored mail and attachments from Postbox app (Mac OS)”

Manually verifying created users when using Laravel Email Verification

Laravel 5.7 ships with bundled Email Verification. This is great if you want to make sure a user’s email address is valid (or at least that the user can access it) before allowing them access.

Problem:
What if you want to manually verify a user without sending them an email address? For example you might want to add or import a load of existing ‘known-good’ users to a migrated app. Or you might be creating Admin or System users that don’t really have accessible email addresses. There could be many reasons.

At present as soon you register a user, the sendEmailVerificationNotification method is called. There’s a good breakdown of how this works in this Stack Overflow answer. If a user is manually created, then when they try to log in they’ll still see the “Verify your email address” message:

Laravel's email verification message

Solutions:
Whether a user has verified their email address or not is indicated by a timestamp in the email_verified_at column of the User table¹. If this column is set to a valid timestamp upon user creation, the user will be ‘validated’ and no email will be sent. So… how can we set that timestamp?  Continue reading “Manually verifying created users when using Laravel Email Verification”

Fixing “[vue-loader] vue-template-compiler must be installed as a peer dependency”

Problem:
Whilst attempting to upgrade an old Laravel project, I hit the following error.

Module build failed (from ./node_modules/vue-loader/lib/index.js):
Error: [vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options.

Solution:
After some searching of GitHub and stackoverflow, it turns out that The vue and vue-template-compiler module version must be the same. Here was my existing package.json:
Continue reading “Fixing “[vue-loader] vue-template-compiler must be installed as a peer dependency””

Stop WordPress installing new bundled themes and plugins when the core is upgraded.

Problem: Every time WordPress updates to a newer major version it tries to install the newest default Theme too, i.e. WP5.0 arrived with the theme Twenty Nineteen.

In many – maybe MOST cases – we aren’t going to want this to happen on an existing WordPress installation, especially if you are already using a custom theme.

Solution: Thankfully there’s a config value to stop this happening. The value is:

define('CORE_UPGRADE_SKIP_NEW_BUNDLED', true);

…and if you add this line to your `wp-config.php` file (usually found in the root of your site) it will skip new bundles items when the core is upgraded, as the name suggests.

Please let me know if this post was useful with a click, be honest 🙂
Nope, not helpful...Yep, more useful than not! - +1 thumb, 5 overall.
Loading...

Vacuum hose tee and better routing on the GT6

Problem: The routing of the vacuum hose on the GT6 is a bit poo. Actually I don’t know what it was like from the factory, but most engine bays I’ve seen recently have it draped around the rocker cover or across it, and that can lead to problems.

Solution: I wanted to fix the hose to one of the rocker shaft studs as a more secure solution but couldn’t find a suitable hose clamp with an appropriate drilling. Hence this: Continue reading “Vacuum hose tee and better routing on the GT6”

Vacuum advance hose fix with WD40 nozzle

Problem: On a trip home from North Wales, the vacuum hose in my GT6 came loose and fell on the exhaust, melting and fusing it. Nasty sluggish acceleration  resulted.

Solution: I had no tools besides a knife and no spare hose, but DID have a small can of WD40 in the boot.  Continue reading “Vacuum advance hose fix with WD40 nozzle”

GT6 / Spitfire DIY alternator bracket improvement

Problem: Years back when I first did an alternator conversion on the GT6 the very rudimentary ‘pull it hard and tighten the nut’ fan belt tensioning method really annoyed me. It seemed there should be a way to achieve finite adjustment, and not risk noisy, slack or dangerously tight belt tension.

Solution: I don’t remember where now, but somewhere I saw a rigging screw (sometimes called a Turnbuckle). They are available in a load of sizes, lengths and materials from chandlers (sailing suppliers). So I used one of these to solve the problem. I then went on to sell them for a while on eBay under the name Mere Components. Continue reading “GT6 / Spitfire DIY alternator bracket improvement”