ohffs

Experience

223,470

299 Best Reply Awards

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

29th April, 2017

ohffs left a reply on What Made You Choose PHP As A Server Side Language? • 5 hours ago

I started web stuff back when you'd just drop a Perl/Bash/binary into /cgi-bin/ and hope for the best ;-) I switched from Perl to Php for web stuff as it had a lot of things that made doing html/http stuff really easy - it was also easy to get it working with apache & mod_php.

I played with ruby a bit in the earlyish 2000's and rails when it first came out. I really like ruby, but just didn't have the time to learn it properly - it was competing with Perl at the time and didn't really have anything to compare with CPAN or the cross-OS support that Perl had. My memory of early rails is that it was shifting almost constantly and I got fed up with it.

I tried out some of python's web stuff at various times, but it never really clicked for me. Certainly not enough to make it worth using over PHP. I've written fairly large applications in Python, but for the web I don't really see an advantage unless you're already wedded to it.

I used node for a while for small-ish api stuff - but again, the churn was really annoying. More recently I've done a lot of api/microservice stuff with Go. It's really nice - especially if you're familiar with 'plain' C. But again, I don't think I'd use it for website stuff - PHP lets me do that cross-platform & OS and, well, easily ;-)

As for PHP itself, there's nothing I especially hate about it. It's fairly straightforward - no particular theoretical axe to grind or way of thinking laid down, no special tooling or setup. It lets me get work done.

28th April, 2017

ohffs left a reply on How To Check If Given Email Was Real ? • 20 hours ago

Some ISP's don't bounce an email for hours, or even days

Additionally, many don't generate bounces at all due to backscatter. I used to run a fairly busy mailserver and eventually disabled bounces for anything outside my domain. Though I started in ye olden days and you could still send vrfy commands over smtp - but those days are long gone due to spammer running vrfy commands for every combination of names to find valid addresses :-/

Other than a confirmation as @Cronix suggests, there's not much you can do automatically.

ohffs left a reply on Custom Collection Class Not Found • 23 hours ago

Heh - we've all been there :-) Glad that fixed it :-)

ohffs left a reply on Custom Collection Class Not Found • 23 hours ago

Missing a namespace on the MentionCollection?

27th April, 2017

ohffs left a reply on How To Put My Laravel Project On Git • 2 days ago

ohffs left a reply on Search For Plugin For Db Slug Generation • 2 days ago

https://github.com/spatie/laravel-sluggable might cover most of what you want.

ohffs left a reply on Naming Controllers - When Is A Controller Not A Controller • 2 days ago

It sounds like it should be it's own 'thing' rather than a 'controller'. Something like app/Social/Feed.php? Then just pull that in to the controller(s) where needed? Ie,

use App\Social\Feed;

class HomeController
{
  public function __construct(Feed $feed)
  {
    $this->feed = $feed;
  }

  public function index()
  {
    $whatever = $this->feed->fetch();
    return view('...

ohffs left a reply on Laravel Book • 2 days ago

I enjoyed Refactoring to Collections. I learned quite a few new things from it that I've been able to make use of in real projects.

ohffs left a reply on For How Long A Laravel Application Can Run. • 2 days ago

It's maybe worth pointing out that the OS vendor might support their version of PHP for different times than the official PHP project does. For instance RHEL/CentOS 6 came out in 2011, ships with PHP 5.3 and is supported until ~2020 even though 5.3 was officially dropped in 2014.

26th April, 2017

ohffs left a reply on Repositories • 3 days ago

public function __construct(\App\User $repo)
{
  $this->repo = $repo;
}

;-)

ohffs left a reply on Repositories • 3 days ago

No :-)

25th April, 2017

ohffs left a reply on Compatibility Between Laravel Versions? • 3 days ago

There are quite often API changes between even minor versions - which can be annoying to say the least. Mostly it's usually a case of updating a few files - but sometimes there are bigger changes that can come out of the blue and bite you.

There are 'LTS' releases (5.1, the upcoming 5.5) which would mean you just sat on that version for a year or two - but that can bring it's own issues. I guess you need to choose which path you're happier on :-)

I've been using it since around v4.0 and the core stuff I care about hasn't changed all that much - and most of the changes have made life better. I don't think it's hugely different to keeping up with any other framework (or even language). If you want the new shiny features because it'll make your life easier/better then you need to keep an eye on it - if you want a more 'fire and forget' then you can go that route.

And as @goatshark says, laravel shift is a really handy service that can take care of a lot of the grunt work for a pretty reasonable cost if you're willing to spend on it :-)

ohffs left a reply on Import Excel • 4 days ago

No worries - I use it all the time - glad to spread the word :-)

ohffs left a reply on Import Excel • 4 days ago

You could grab all the existing unique_id's into an array before starting the import, then check if they exist that way? Something like :

$existingRecords = Model::pluck('unique_id');

...

if ($existingRecords->has($sum)) {
  // update
} else {
  // insert
}

22nd April, 2017

ohffs left a reply on It Was All Going So Well • 6 days ago

Hrm - are you definitely useing the right mailable in the test? I've been caught (oh so many times!) because I'd typo'd or forgotten the name at the top of the test. So I'd do something like :

use Almost\Spelled\RightMailable;
...
Mail::assertSent(RihgtMailable::class...

And it'd keep failing because I'm an idiot ;-)

Other than that - if you take out the mail fake, does it send the mail? I realise it does in the rest of the app, but just in the test? Again, just really trying to see where it's not happening. Also - and this is something I've done in desperation before - put that one test into it's own test class and run that alone. I was bitten once by a fake that seemed to persist across tests and messed the later ones up :-/

As I'm also a fan of sod's law - I'm totally now seeing you spending ages getting this test to pass, then it stops working in the real app ;-)

ohffs left a reply on It Was All Going So Well • 6 days ago

What does $this->job do/look like? If you dd() inside the handle method, is it being run? And if you do a direct call of the Mail::to before the assertion does it pass? Just to narrow down where it's going missing :-)

21st April, 2017

ohffs left a reply on How Much Do You Earn? • 1 week ago

Ah - the US$1500 is the national minimum wage in the country. At least in theory ;-) A junior dev (probably with a degree) in most of the country would be looking at a ballpark US$2500/month before tax etc. But plenty of places pay less and London in particular can pay a lot more - but the cost of living is much higher than the rest of the country so you might not be any better off.

If you go to that cost of living calculator I linked to you can get a very rough idea of the amount you've have to earn to keep a reasonable life outside of work.

I think dev's in a lot of the world are undervalued because people don't really understand what it is we do, or how much you need to know. I once had someone quite senior say to me 'well, it's just typing!' ;-) People can use things like Facebook to put a 'website' online - I mean, how hard can it be just to do something a bit more than that? ;-)

Some sectors value developers much more than others though - working in finance, oil (in times gone by anyway) and some other niches can make you more valuable. Sometimes it's just luck - you make a contact who puts in a word with someone else and you become the 'go to' for them and they're happy to pay.

20th April, 2017

ohffs left a reply on Laravel Relation For Different User Types • 1 week ago

My answer could give unexpected results using with() clauses - but as the original question wanted to use it directly as a relation it's fine I think. But something to be aware of down the line. If you're going to be doing reporting or something that uses the with() then you'd probably want to break it out to something like :

// the 99% use-case
public function orders()
{
  if ($this->is_shop) {
    return $this->shopOrders();
  }
  return $this->supplierOrders();
}

public function shopOrders()
{
  return $this->hasMany(Order::class, 'created_by');
}

public function supplierOrders()
{
  return $this->hasMany(Order::class, 'fulfilled_by');
}

// then
foreach ($user->orders as ....

// or
$whatever = Auth::user()->with('shopOrders')->....;

ohffs left a reply on Clicking On The Server Link Does Not Work • 1 week ago

You'll have to google about for whichever terminal app you're using.

ohffs left a reply on Clicking On The Server Link Does Not Work • 1 week ago

He's using iterm2 on a Mac - when you cmd-click a url it will open the default browser.

ohffs left a reply on Laravel Relation For Different User Types • 1 week ago

The easier way to do it might be to check and return a different relation :

  public function orders()
  {
      if ($this->is_shop) {
          return $this->hasMany(Order::class, 'created_by');
      }
      return $this->hasMany(Order::class, 'fulfilled_by');
  }

19th April, 2017

ohffs left a reply on Mock Response During Dusk Testing • 1 week ago

Add a key to your dusk .env file? Something like DUSK=true. Then you can check by if (env('DUSK', false)) { ... }

ohffs left a reply on Mock Response During Dusk Testing • 1 week ago

Why do you have the check for 'cli'?

ohffs left a reply on Mock Response During Dusk Testing • 1 week ago

The easiest way might be to do a similar thing to the dusk test provider. Eg,

    public function register()
    {
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
            $myMock = Mock::....;
            $this->app->instance(AmazonThing::class, $myMock);
        }
    }

ohffs left a reply on I Have Found A Webhost That Works With Laravel (not VPS) • 1 week ago

I think it'd be really helpful if you could link it up with some notes - the 'how do I host without a VPS' question comes up quite a lot so it'd be great to be able to point people at a helpful post :-)

17th April, 2017

ohffs left a reply on How Much Do You Earn? • 1 week ago

I think without also taking into account things like taxes, cost-of-living, average salary in the country etc - you're not going to get a very meaningful set of numbers.

For instance in the UK, an adult working a 40hr week would earn a minimum of roughly US$1500. But after tax, food, rent, travel etc - they're likely to pretty broke at the end of the month.

Your best bet is probably to look at job advert sites in other countries and see ballpark salaries for jobs asking for similar experience/skills as you have - then dig around for numbers comparing the cost of living etc. For instance like this site

16th April, 2017

ohffs left a reply on How Block TokenMismatchException In VerifyCsrfToken.php In Production When It Is Produces • 1 week ago

What is your APP_ENV set to in your .env file?

15th April, 2017

ohffs left a reply on Does Anyone Use Sketch? • 2 weeks ago

Ah - right. I've seen it before but I don't really do much in the way of front-end stuff that isn't just bootstrap/bulma/whatever so it's not something I'd get much use from.

ohffs left a reply on Does Anyone Use Sketch? • 2 weeks ago

It might help if you linked to what sketch is?

14th April, 2017

ohffs left a reply on How Does Jeffrey Make Screencasts Without Keyboard Sounds? • 2 weeks ago

He is renowned across the industry for his very, very soft fingertips.

Or possibly he uses a good microphone close to his mouth so it doesn't pick up the clicks.

mic

But I still think it's the kitten-soft fingers... ;-)

ohffs left a reply on SQL Query To Alter A Table With Proper Positioning • 2 weeks ago

Do you mean in a migration? You can do :

$table->unsignedInteger('customer_id')->after('date');

ohffs left a reply on XML Feeds URL Works In Browser But Get Timeout When Using CURL • 2 weeks ago

If you use a plain php file_get_contents, does that work ok?

ohffs left a reply on How To Deploy To VPS Without Forge • 2 weeks ago

Where did you buy the domain? The site will usually let you point your DNS records to your VPS's IP address. Then you just set up a vhost as in the tutorial above that takes the right domain name and points it the directory with your project.

ohffs left a reply on How To Deploy To VPS Without Forge • 2 weeks ago

Once you've installed all that - then you're just really needing to set up a vhost and create your initial db. There are some helpful tutorials from digital ocean on the basics. Though you'd obviously want to git clone your own project rather than install laravel itself as is done in the tutorial.

ohffs left a reply on How To Deploy To VPS Without Forge • 2 weeks ago

You could use something like deployer to handle the actual deployment. But do you mean you don't know how to set up the webserver etc too?

11th April, 2017

ohffs left a reply on VPS Weird Behavior • 2 weeks ago

40 megabytes?! Have a try of set_time_limit(0); before you start sending the data as a temporary test and see if that works.

ohffs left a reply on Using Laravel 5.4 Testing With External Domains • 2 weeks ago

Have a look round this repo

10th April, 2017

ohffs left a reply on Common Reasons For Intermittent Very Slow Profile Times For CreatePdoConnection? • 2 weeks ago

It's just a common source of intermittent/un-explained slowness. There are a lot of things which could be the cause outside of that I'm afraid :-/ Maybe try writing a tiny php script outside of your main application which just times opening/closing connections and see if it sees the same things at the same time? If it shows similar results try leaving a 'ping' command running and see if that shows up too.

There are a few monitoring tools for postgres itself that might also give you some insights - https://github.com/julmon/pg_activity for instance.

ohffs left a reply on Common Reasons For Intermittent Very Slow Profile Times For CreatePdoConnection? • 2 weeks ago

Possibly DNS? Are you using a hostname to connect, or the IP address? If you're using the hostname, see if switching to the IP helps.

9th April, 2017

ohffs left a reply on Laravel Mix For Simple Project... • 2 weeks ago

If it's just simple 'plain' javascript, why use mix/webpack at all?

ohffs left a reply on Best Way To Schedule Large Amount Of Tasks • 2 weeks ago

Guzzle has some nice async/concurrent features now. See http://docs.guzzlephp.org/en/latest/quickstart.html#concurrent-requests for instance. I'd still be tempted to make them into queued jobs mind you.

8th April, 2017

ohffs left a reply on Getting Artisan::call() Return Values? • 3 weeks ago

I was meaning that the code for whatever it is your doing is in it's own class, then you call that from both the controller and the artisan command. So you end up with :

// in artisan 
public function handle()
{
    $thing = new MyMagicCode();
    $thing->doSomething();
}

// in controller
public function whatever()
{
    $thing = new MyMagicCode();
    $result = $thing->doSomething();
    ...
}

6th April, 2017

ohffs left a reply on Login Via Active Directory And Limited Access • 3 weeks ago

Before you call any auth methods, check if the username is one you want to allow? You will probably have to over-ride the login() method on the LoginController.

5th April, 2017

ohffs left a reply on Redirect::('/whatever') Doesn't Work On Production. • 3 weeks ago

Heh - no problem - we've all been there :-)

ohffs left a reply on Redirect::('/whatever') Doesn't Work On Production. • 3 weeks ago

Maybe try setting the APP_ENV to 'local' for a moment to get the full on-screen dump?

ohffs left a reply on Redirect::('/whatever') Doesn't Work On Production. • 3 weeks ago

When you say 'doesn't work' - what's actually happening?

ohffs left a reply on Getting Artisan::call() Return Values? • 3 weeks ago

In the past when I've needed this kind of thing I've extracted a class which does the task - then just called that class from my controller and artisan command rather than try and call artisan itself from the controller.

Might be easier to go down that path?

ohffs left a reply on Testing Books • 3 weeks ago

Chris Hartjes has a couple of good ones - I have the 'minimum viable testing' one :

https://grumpy-learning.com

3rd April, 2017

ohffs left a reply on I'm Starting To Hate Laravel • 3 weeks ago

@MikeHopley and I used to think you were a serious dev too - how I was misled! You should go over to reddit and learn how the pro's do it... ;-p

ohffs left a reply on Advice Please On How To Test Real Order Data (to Check That It Tallies Correctly) • 3 weeks ago

No worries - glad it helped :-)

Edit Your Profile
Update

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