271 Best Reply Awards

  • Member Since 1 Year Ago
  • 599 Lessons Completed
  • 2 Favorites

21st February, 2017

ohffs left a reply on Laracon Online • 15 hours ago

I totally clicked the right icon this time! I win at life! :-D

ohffs left a reply on Laracon Online • 15 hours ago

@SaeedPrez oops - gave you the correct answer thing instead of clicking the 'thumbs up'. I am an internet master... ;-)

ohffs left a reply on Laracon Online • 16 hours ago

@SaeedPrez no worries - it's a pretty nice deal for US$10 :-) I don't have a slack account so won't be doing anything live for it either - antisocialness ftw! ;-)

ohffs left a reply on Laracon Online • 16 hours ago

Just bumping this as it's the last day of early-bird prices :-)

ohffs left a reply on Upgrading A Messy 4.2 App To 5.4 • 16 hours ago

@meath I'm also migrating a c100k line php 4 app to laravel - it's a whole world of weird, misleading, buggy, awfulness. I started out thinking 'I'll just re-write it - it's too awful' but realised it was a terrible mistake after a month or so.

There's just so much strangeness tied up in old code that you miss when you're reading it and thinking 'Oh, it's just getting that thing from the db and adding one to it'. Then you notice your new code isn't showing quite the same result as the original because you hadn't spotted there was a global variable, or some bit of hidden magic or a method name subtly didn't match what the thing actually did.

You have my sympathies in any case! :-)

ohffs left a reply on Upgrading A Messy 4.2 App To 5.4 • 18 hours ago

I've migrated 4.2 apps to 5.x before - some of them were terrible. In general, I prefer to migrate the code 'as is' and refactor it rather than do a re-write. With old horrible code you are never sure if you've missed some weird side-effect or 'bug-that-is-a-feature' when you're re-writing it.

If it's JS heavy you might be able to use the new Dusk tests on the side to write some tests of the system so you know you've not broken too much :-). See the 'utility bill' example for how you can use it for instance :


ohffs left a reply on Laravel Admin Template - Chandra • 18 hours ago

I use the 'does all the things and meets all the requirements' package from GitHub.

20th February, 2017

ohffs started a new conversation Laravel 5.5 *will* Be A LTS Release • 1 day ago

Seeing as this has come up a few times - seems official now that 5.5 will be a LTS release.


ohffs left a reply on Config To Allow Old Codebase • 1 day ago

I'm in the process of moving an old codebase towards Laravel - I'm following the path @primordial suggests using. Pull in some parts of the framework like Eloquent and Blade and start slowing 'larval-ising' the code.

Matt Stauffer's 'torch' repo might help showing how to use the components outside of the framework :


18th February, 2017

ohffs left a reply on Voting Functionality: Database Vs Redis • 3 days ago

I think if you're going to have a lot (like 100's a second) of voting going on, then redis might be useful just to relieve your DB from doing a lot of writes when it could be doing something more useful.

Or if you're already using redis a lot for other, possibly related, data - then again I'd consider it.

But mostly none of us are 'lucky' enough to be so popular so can just stick with a boring old sql server ;-)

17th February, 2017

ohffs left a reply on DatabaseMigrations Trait In 5.4.12 • 4 days ago

Sorry for the bump - I've 'solved' this for now by using an in-memory sqlite rather than on-disk. Can't see anything on the github issues page so might keep digging to see why I seem to be so special... ;-)

ohffs started a new conversation DatabaseMigrations Trait In 5.4.12 • 4 days ago

Just in the process of migrating an app to 5.4 and trying out some basic tests and noticed that they were beginning to fail. It looks like the migrations trait isn't resetting the db after the tests.

So I have a test made with make:test and a very simple example :


namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class StupidTest extends TestCase
    use DatabaseMigrations;

    public function testMigrations()
        $user = factory(\App\User::class)->create();

And running produces :

[[email protected] projects2]$ vendor/bin/phpunit --filter StupidTest
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

[[email protected] projects2]$ vendor/bin/phpunit --filter StupidTest
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

[[email protected] projects2]$ vendor/bin/phpunit --filter StupidTest
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

[[email protected] projects2]$ vendor/bin/phpunit --filter StupidTest
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.


Using database transactions works ok - but I'd quite like the migrations to work really ;-) Anyone else hit this?

16th February, 2017

ohffs left a reply on Laravel Dusk Without Laravel • 5 days ago

It's certainly possible. I'm thinking about using it with an old legacy project that has zero tests on the original code.

This might give some inspiration (and some implementation ideas) : https://laravel-news.com/automatically-making-monthly-payments-with-dusk

15th February, 2017

ohffs left a reply on Dusk Vs BrowserKit? • 6 days ago

@SaeedPrez yeah - it's pretty impressive :-) I'd still like plenty of other people to beta test it for me before I got in one though ;-) If it saves me talking to taxi drivers or listening to people talk crap on the bus I'm all for it ;-)

I can't help feel that we've taken this thread a bit away from the original question mind you... ;-) Sorry original poster!

ohffs left a reply on Dusk Vs BrowserKit? • 6 days ago

@SaeedPrez part of me always thinks "I barely trust my usb stick to work, never mind an autopilot taxi". I sometimes wish I knew less about how crappy most IT is... ;-)

ohffs left a reply on Dusk Vs BrowserKit? • 6 days ago

@SaeedPrez I don't even have a drivers license ;-) I'm holding out for robo-cars (or jetpacks) ;-)

ohffs left a reply on Dusk Vs BrowserKit? • 6 days ago

@SaeedPrez I keep feeling like I'm missing something or doing something stupid :-/ I'm middle-aged enough to feel that while just sitting on the bus - I don't need my tools laying it on me too... ;-)

ohffs left a reply on Dusk Vs BrowserKit? • 6 days ago

I feel your pain. I'm trying to migrate a 5.3 app fully over to 5.4 and it's all great apart from the testing :-/

It does feel like we're being encouraged to go "plain http + dusk" judging by the docs (no mention of browserkit outside the upgrade guide for instance). But dusk doesn't do some of the things that browserkit did (I realise it does a lot of things browserkit couldn't of course), and the plain http is missing most of the rest.

I've got my regular unit-esque tests handling the inner logic, but just all the "bread and butter" tests like "person X can fill in this form and save it", "only a person of type Y can see button Z" etc are now painfully slow or I have to write really long series of ugly plain http get/post requests and assert against those.

Maybe I'm an outlier in that I use javascript very, very rarely in my apps (usually just the occasional 'datatables' plugin or something) so I'm not getting all the upsides of dusk - just the downsides. But it's really puzzling that browserkit was ripped out rather than giving us something like "Basic Browser Testing" / "Advanced Browser Testing".

As it is I'm not sure what to do. Keep going with dusk and just live with not running the tests very often due to the speed (the entire test suite for this app used to run in ~6seconds, now the tests for the single form I've converted to dusk take ~8seconds), or "hope for the best" that browserkit isn't going away...

13th February, 2017

ohffs left a reply on Discussion: Best Validation Approach • 1 week ago

I tend to treat front-end validation more as a help for users. So they know 'you need to fill this in', or 'that can only be a number between 1 and 100' - it's a happy side-effect that it saves submissions to the back end.

The back end I do the same validation (pretty much). Given you can never be quite sure of the front-end, you need to save yourself at that last gate before you let the data in :-)

12th February, 2017

ohffs left a reply on MacBook Air Or Pro 13 • 1 week ago

I just got a 13" pro and it's quite nice. The new touchbar thing seems a bit useless to me - but then I spend 99% of my time with just a browser/terminal/editor and none of them do much with it. The keyboard is a bit... 'interesting' too - but I'm getting quite used to it now.

I needed the extra ram as I've got to run a lot of VM images for legacy code - if you can get away with using something like Valet then you could probably save a lot of cash and stick with an air.

ohffs left a reply on Cannot Execute Python Script? • 1 week ago

@ctaljaardt thank you! I'm really just playing about with it just now - seeing if I can get it to recognise the orientation of etched lines on silicon wafers and then normalise the position/angles. It's just an excuse to play around with it really - but if it works out I might pester you ;-)

11th February, 2017

ohffs left a reply on Cannot Execute Python Script? • 1 week ago

Ah! Glad you got it going :-) I'm playing about with tensorflow a little just now too :-)

ohffs left a reply on Cannot Play Video OSX Safari • 1 week ago

Maybe related to the new video on here about adding adverts to videos? It sounds like safari is trying to do the right thing though. It plays ok for me in safari 10.0.1 - no plugins/ad-blockers etc.

@CrushCandy urm... I've got chrome running fine on OS-X - installed it on a new mac yesterday...

ohffs left a reply on Cannot Execute Python Script? • 1 week ago

What happens when you run the python script in the terminal rather than via php?

10th February, 2017

ohffs left a reply on Rather New To Testing, How Do I Test A Method That Contains $model->save() • 1 week ago

@komirad your best option really is to just hit a db - an in-memory sqlite one is ideal if you don't want to hit the disk or set anything up. You don't need to worry about it having side effects or being drastically slow.

I guess I'm looking at your code and imaging you want to have a series of tests something like :

if there are existing adGroups with a given ID,
then when I call syncAdGroup with that ID,
the adGroups will be updated with whatever syncBack() does...

if there are no adGroups with an ID of 5,
then when I call syncAdGroup with an ID of 5,
... etc

So just testing that a ->save() method was called isn't very helpful. For instance, in a years time someone (maybe you) changes the code a little and now doesn't call ->save() but calls, say, ->update(). Now your test breaks even though the code is still achieving the correct goal.

I guess another way of thinking about it is - imagine you had those test descriptions - but didn't know the implementation of the syncAdGroup() function and had to write tests for them - then how would you do it? It's fairly unlikely you'd do it by mocking out an object and making sure a save() method was called? I think ;-)

It's Friday afternoon and I'm possibly rambling a bit though... ;-)

ohffs left a reply on Rather New To Testing, How Do I Test A Method That Contains $model->save() • 1 week ago

Assuming that AdGroup is an eloquent model - then you're going to be trying to swim upstream to avoid using any kind of database to test actual database methods were run on it. Using an in-memory sqlite db is way easier than trying to work around it. Or consider re-writing your code so it's easier to test the logic?

ohffs left a reply on Mocking A Service On 5.4 Using 'Dusk' • 1 week ago

Yeah - I migrated some tests yesterday. I guess I was a bit overly optimistic about what dusk would do - basically be a drop-in replacement for browserkit - "but better!"(tm) ;-)

As for now I've ended up with a bit of a mish-mash of tests/Browser, tests/BrowserKit, tests/Unit which makes it a bit tricky to remember which Browser* tests do which things.

Combined with the changes to the tests having namespaces (or not, or maybe) it was a bit more work than I anticipated though. I think it took me about ten minutes to upgrade the main codebase to 5.4, then about 2hrs to try and figure out the testing stuff :-/

I really hope Jeffrey covers this is in a bit more detail - it's the first time in a long while I've felt like I'm just muddling through using guesswork with Laravel :-/

9th February, 2017

ohffs left a reply on Homestead And Valet On Same Mac? • 1 week ago

I've only recently started using valet - I only use it for new-ish 'framwork' stuff though as most of the legacy code I've got is very picky about php versions, filesystem paths etc - so using plain vagrant for those is easier. It's also easier to share older legacy code if you can provide the setup for a vagrant box as it's cross-platform and doesn't need people to set up sql/php/whatever on their own OS.

Vagrant/homestead/valet will happily co-exist on the same machine though - which is I guess your question?

ohffs left a reply on Implicit Controllers - Laravel 5.4 • 1 week ago

Ah, so polite...

8th February, 2017

ohffs left a reply on Why Won't Composer Load My Classes By Default? • 1 week ago

Have you ever run any of the optimize-esque artisan commands? I seem to have a vague memory that they generate "optimised" class loaders - could be something is getting confused.

ohffs started a new conversation Laracon Online • 1 week ago

Didn't spot this being posted - but it looks a pretty nice deal (especially as the early bird tickets are US$10) :


ohffs left a reply on ConvertEmptyStringsToNull Middleware For What!? • 2 weeks ago

I do kind of wish the framework had a 'blessed' sanitiser - there are quite a few packages around, but it feels like it should really be part of the framework like validation is, eg:

  'username' => 'trim|lowercase',
  'country' => 'trim|to_null',

ohffs left a reply on Mocking A Service On 5.4 Using 'Dusk' • 2 weeks ago

@georaldc yeah - it's a bit annoying :-/ I realise why it's working the way it is - but it's still annoying ;-) I need to do some tests of code that talks to a corporate LDAP server which I have no control over, so previously I mocked it out. So now I need to keep using browserkit tests for those parts rather than dusk - and it vaguely worries me that the browserkit package won't be kept around. Hey ho!

7th February, 2017

ohffs left a reply on ConvertEmptyStringsToNull Middleware For What!? • 2 weeks ago

ConvertEmptyStringsToNull decides for me. It's not good.

.. Well, don't use it then? o_O

ohffs left a reply on Slowly Rebuilding A Legacy PHP App In Laravel • 2 weeks ago

I feel your pain - I'm slooowwwwlllyyy migrating an old PHPv4 (yes) app that's c100k lines of impenetrable gibberish built up over 10-15 years :-/ It also has a home-grown "soft deletes" - although the soft-delete column name changes depending who was writing that particular bit of code. Which is... nice...

If I were you I'd go with your migration plan and add the extra column. It's the 'path of least surprises' I think.

Good luck! :-)

ohffs left a reply on Allow Remote Mysql Access • 2 weeks ago

Is this just for kinda debugging purposes? If so the easiest way might be to use an ssh tunnel

6th February, 2017

ohffs left a reply on Problem With Testing Mails With Smtp Driver • 2 weeks ago

Maybe have a look at mailthief or the new built-in testing code - might work better than what you're using just now :-)

ohffs left a reply on Hide/show Button On User Login • 2 weeks ago

Something like :

@if (Auth::check())
  <your button>

4th February, 2017

ohffs left a reply on Do I Need To Prepend The APP_URL Env Variable With 'http://'? • 2 weeks ago

The docs say to set it - so you might as well take the five seconds ;-) Unless you have a really good reason you don't want to?

ohffs left a reply on Laravel Dusk Opening Opening Browser Window • 2 weeks ago

I've only run the browser/dusk stuff a little bit - but I got the impression it was opening the browser window if the test lasted more then $some_amount_of_time (or needed to take a screenshot). But that might just be that it was opening & closing so quickly for short tests that I didn't see it.

I think for a lot of tests you're now supposed to do things like :

$response = $this->get('/some/page');
$response->assertSee('some text');
// etc
// rather than
   ->see('some text');

The more $browser-> style ones are for testing JS etc. I may well be wrong though.

But it's not very clear to me and there's no real guidance on migrating tests from < 5.4 so it's all guesswork at the moment :-/

ohffs started a new conversation Scheduled Command Not Sending Emails • 2 weeks ago

I've got an artisan command that sends out email alerts. It sends them out ok if I run them from a terminal, but not if they're sent if the command runs via the scheduler/cron. The rest of the logic in the command does run - just the emails aren't being sent (not even hitting the smtp server so not a spam/whatever issue).

I've tried adding the register_argc_argv = on php ini setting just in case and it's made no difference.

The command doesn't do any console/logging - purely updates a flag on some models and calls notify(). There's nothing being logged in the laravel logs.

Anyone else hit this? I'm possibly doing something stupid - but it's just odd that running it by hand in the terminal works a-ok.

3rd February, 2017

ohffs left a reply on Starting Out A Big Web App • 2 weeks ago

@fahaddsheikh don't worry too much. You probably will have to redesign bits, change things, etc. That's all part of a site's life :-) Much though I wish I could just write some code then never touch it again ;-)

Transactions are useful - but don't set out thinking they will prevent all problems :-) If they did they would be on by default on every DB engine ;-) Sketch out your code and see where a transaction might make sense rather than wrapping everything inside one by default.

If I were you I'd just get a prototype going as best you can - then sit back and have a think, change a few things, have a think, etc. Once you've got a prototype at least you can play with the site, try running some benchmarks on it to see where things go slow etc.

ohffs left a reply on Starting Out A Big Web App • 2 weeks ago

@fahaddsheikh as @mformarshall says - don't start out worrying too much about "web scale" or anything. I mean - don't start out thinking 'bah - doesn't matter, I'll just use CSV files instead of a DB...', but don't sweat it too much. If you do you'll end up with a hundred AWS cloud servers, caching infrastructure and a bill bigger than twitters - with a dozen people trying out your site ;-)

On the other hand - you can build an amazing design you've thought about for months, added auto-scaling, multi-region fallover, capable of handling a million simultaneous users, etc - then the first dozen users do something you didn't anticipate and it all falls over anyway ;-)

Just take a bit of care over your code and DB design and you're going to be able to handle plenty of traffic :-) Once you're going you can see where 'hot spots' are and do something about them. Sometimes that will involve re-thinking your design, but often it can just be something like "That side-bar of popular posts could just update once an hour instead of every page-load - I'll cache the whole html snippet for 60 minutes".

ohffs left a reply on Starting Out A Big Web App • 2 weeks ago

I think unless you are really dealing with a seriously large amount of data/traffic or you seriously mess up your database design - dealing with tables that are in the thousands of rows shouldn't be a problem on a modern sql server.

Just make sure you properly design your tables so it's easy to look up the things you will often look up (eg, make sure you tell the DB that a 'thing_id' relation column is a foreign key (don't just make it an integer and leave it at that), add indexes to commonly looked-up columns etc). All of that helps the database optimise it's queries when looking up data.

ohffs left a reply on Upgrade Tests To 5.4 • 2 weeks ago

It's puzzling that the new dusk tests don't follow the same syntax as the old ones. I've already sat quietly swearing at them as the browserkit ones did ->type('value', 'field') and the dusk ones want ->type('field', 'value').

I'd kind of expected to pretty much replace $this-> with $browser-> for basic tests. I'm sure there's a good reason - but it's quite annoying all the same.

ohffs left a reply on Mandatory Migrations ? • 2 weeks ago

If you don't use the migrations at all then you might be fine. It's mixing manual & migrations that usually throws up problems. Imagine your migration has a column marked as an integer, but you've manually changed it to a float, or a string changed to a text blob etc.

If you go manual, you also need to watch out for 3rd-party package which do use migrations - then you could be in a more complicated situation.

In general - use migrations :-) They're a Good Thing(tm) :-) Even something as simple as sharing code becomes much easier if the other person can just run the migrations and know they've got the same set-up as you do - if they make a change, you get it too without having to manually sit doing 'alter table...' yourself.

2nd February, 2017

ohffs left a reply on Mocking A Service On 5.4 Using 'Dusk' • 2 weeks ago

Just a note/bump to say I've tried dropping back down to the browserkit testing via https://github.com/laravel/browser-kit-testing but that seems to not install a required symfony component and I'm wary of starting to mangle things by hand.

I totally love programming... o_O

ohffs started a new conversation Mocking A Service On 5.4 Using 'Dusk' • 2 weeks ago

I'm probably doing the Wrong Thing(tm), but.... I was wanting to try out dusk on a new project - I've copied a tiny bit of code from an old test into the new one. It uses the prophecy code and worked fine in 5.3 using the regular browser testing. But in 5.4 with dusk it doesn't seem to ever "mock" the class so it keeps trying to hit the real service and failing.

The test looks like :

use Tests\DuskTestCase;
use App\Auth\Ldap;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class LoginTest extends DuskTestCase
    use DatabaseMigrations;

    public function test_a_valid_ldap_user_can_log_in()

        $this->browse(function ($browser) {
                    ->assertSee('Log In')
                    ->type('username', '0000000x')
                    ->type('password', 'secret')
                    ->press('Log in')
                    ->see('Testy McTest');

    protected function fakeLdap()
        $ldap = $this->prophesize(Ldap::class);
        $ldap->authenticate('0000000x', 'secret')->willReturn([
            "email"=>"[email protected]",
            "username" => "0000000x"
        app()->instance(Ldap::class, $ldap->reveal());

And the Ldap class is resolved by Laravel in the constructor of the login controller. As I say - exactly the same code in 5.3 using the regular browser testing works fine and hits the mocked class. But in 5.4 it hits the real Ldap class and tries to authenticate with ldap (and fails, naturally).

Anyone hit this or can spot something stupid I've done? :-)

1st February, 2017

ohffs left a reply on Mandatory Migrations ? • 2 weeks ago

will this be an issue further down the road

That depends what you do down the road?

ohffs left a reply on Can I Use Laravel Valet On Windows Os • 2 weeks ago

There's also 'Hotel' which is similar-ish and cross-platform :


Edit Your Profile

Want to change your profile photo? We pull from gravatar.com.