0 Best Reply Awards

  • Member Since 1 Year Ago
  • 0 Lessons Completed
  • 0 Favorites

21st November, 2017

nutmix left a reply on How To Compare A Date In A Retrieved Model? • 10 months ago

FYI I cant find a series on VS Code. if I go to series:

Then enter "VS Code", it only returns a single article on how to setup the debugger (which I already have working luckily). "vscode" returns no results.

Any idea where this series is?

nutmix left a reply on How To Compare A Date In A Retrieved Model? • 10 months ago

I read the carbon docs, and it seems you need to use ->lt etc.

For a java developer, it is pretty shocking that php allows my totally incorrect code to run without any errors or warnings.

Anyway, I am guessing I need to do something like this:

if ($model->expire_at->lt(Carbon::now())) { }

but this gives:

Error: Call to a member function lt() on string

My database field is a timestamp.

so either I still have the wrong syntax, or eloquent is mapping timestamps to strings in the model. When I look at the expire_at field (under "attributes")in the VS Code local variables debugger view, it shows it as something like

created_at: "2017-10-18 17:59:17" expire_at: "2017-11-22 03:52:58"

etc. Not sure if this means eloquent maps timestamps onto strings in the model, or that it is doing the java equivalent of "toString()" on it.

nutmix left a reply on How To Compare A Date In A Retrieved Model? • 10 months ago

I tried this:

if ($model->expire_at <= Carbon::now()) { }

But this fails - it evaluates to true even if the expire_at timestamp is less than now, or greater than now.

e.g. if now is 22/11/2017 02:02:02

I am guessing some truncation is going on. I cant find a source code example of a date comparison via google.

nutmix started a new conversation How To Compare A Date In A Retrieved Model? • 10 months ago

I want to see if a timestamp stored in mysql has passed, after reading the row.


$model = Model::find(1);

if ($model->expired_at > NOW) { .... }

The problem is

  1. I don't know what the type of "$model->expired_at" is. Is it a string, such as "2014-01-01 12:12:12" or is it some PHP date/time object?
  2. I don't know what to put in place of "NOW".

Coming from a Java background, PHP not having any type definitions makes it seemingly impossibly to know what you are dealing with, or is there a way to find this out? I am using VS code, and it has zero type hinting or completion unfortunately.

24th October, 2017

nutmix started a new conversation One Route Gives Method Not Allowed For Ajax, But Only When We Deploy To Forge (nginx). The Same Code Works Perfectly On Apache. • 11 months ago

Some of our routes give method not allowed for ajax, but only when we deploy to forge (nginx). The same code works perfectly on Apache.

We are at a complete loss to find what the problem is, and we can't go live. Any help or ideas appreciated.

This is one of the problem routes which doesn't work with nginx:

Route::post('/posts/reskin/{idpost}/{tabnr}/savetext','[email protected]')

It works in apache, but always fails on a forge server (which uses nginx). Laravel is returning "something went wrong" and


This is the request taken from the debugger on a working system which uses apache:

Request URL:
Request Method:POST
Status Code:200 OK
Remote Address:
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Cache-Control:no-cache, private
Date:Tue, 24 Oct 2017 11:16:18 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.27 (Win64) PHP/7.1.10
Set-Cookie:XSRF-TOKEN=eyJpdiI6InQ4MnZ1T2ptTTRzUTA4UzlVSGRWZ0E9PSIsInZhbHVlIjoiUDZoOWo1WU1lWkhEcWRBMmlVOUQ0eUlHVWlqQkdQOHBwZUc0c09mZXlVVFlnVW13c3Z2QVNmVW16ZVJ6SHBLSjhSUENtM1E0bDlHVjRodzJJeGFyR3c9PSIsIm1hYyI6IjUwNzQyYjM2OTMwODlhOWQ4ZTZmZGYyYzhjYWY1YTM5MzdmODM0MDZiOWVlNGUyOTBiNjFhYTU3YmFkOWY0ODMifQ%3D%3D; expires=Tue, 24-Oct-2017 13:16:18 GMT; Max-Age=7200; path=/
Set-Cookie:laravel_session=eyJpdiI6IkR1blRTcU5zNDFGRG04cXpKYzByZkE9PSIsInZhbHVlIjoiVjdIQk8rcUVQZU1kTGE4VUxcL3IwUTNoR1wvbGx1Q25XSFFpOVwveXpyVGdYTWhtRlRSekkrYXUwYktPUW14UG1pSG4zcEdqeXZmK2xVVDRJZ1wveE1PazN3PT0iLCJtYWMiOiI3OWYwMzk4NWMwMTk5NDgzZGZkNjY5ZDUyZWE2ZDBlZDZjNzAxZGYyYmUwYTNhMmUyNTRhMmFmZTNjMGIyYjYwIn0%3D; expires=Tue, 24-Oct-2017 13:16:18 GMT; Max-Age=7200; path=/; HttpOnly
Request Headers
view source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

This is the same post but to a forge server with identical software which fails:

Request URL:
Request Method:POST
Status Code:404 
Remote Address:
Referrer Policy:no-referrer-when-downgrade
Response Headers
cache-control:no-cache, private
content-type:text/html; charset=UTF-8
date:Tue, 24 Oct 2017 11:12:30 GMT
Request Headers
accept:application/json, text/javascript, */*; q=0.01
accept-encoding:gzip, deflate, br
content-type:application/x-www-form-urlencoded; charset=UTF-8
user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

We tried changing the POST method to PUT, but nginx always rejects before it hits laravel with a 405 method not allowed. apparently, you cant use PUT with nginx.

the nginx config is 100% created by forge, and looks like this:

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    include forge-conf/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/ error;

    error_page 404 /index.php;

nutmix left a reply on Nginx Returns 405 (Method Not Allowed) For PUT Or DELETE • 11 months ago

The PUT is a laravel (php) api call, so there should be no write permissions required. We have not put dav_methods into the nginx conf as putting dav handling on a production server would decrease security. however, we will try it.

23rd October, 2017

nutmix left a reply on Homestead + Nginx - PUT/PATCH Requests Using JavaScript • 11 months ago

jRalph, please could you share your complete solution. we are using Ubuntu 16.04, and PUT does not work at all, nginx always gives 405 not allowed

Presumably, the problem part is this:

location / {
    try_files $uri $uri/ /index.php?$query_string;

our URLs look like this:


and our rules look like this:

Route::put('/post/reskin/{idpost}/{tabnr}/savetext','[email protected]');

nutmix started a new conversation Nginx Returns 405 (Method Not Allowed) For PUT Or DELETE • 11 months ago

We are using forge to deploy an standard laravel app.

We use PUT as well as POST, but all puts are rejected by nginx before they even reach laravel:

405 Not Allowed

405 Not Allowed


The nginx config was created by forge.

location / {
    try_files $uri $uri/ /index.php?$query_string;

Our app works flawlessly under apache, but PUTs dont work under nginx/forge

We have exhausted all google responses to this problem, including things like this:

error_page 405 = $uri; 

Which didnt help.

Our PUTs look like this: Request Method:PUT

Laravel routes are defined like this: Route::put('/games/reskin/{idgame}/{tabnr}/savetext','[email protected]');

Although its not even hitting laravel.

If we change the PUTs to POSTS, it then hits laravel, but then larvel returns MethodNotAllowedHttpException from ajax calls for no reason, but again only on nginx, works fine under apache. As there is no solution to this,we want to try using PUT (which some have said solves this exception issue).

20th September, 2017

nutmix left a reply on Which Version Of Php To Install With Windows - Threadsafe Or Non Threadsafe, And Which Version? • 1 year ago

i just took a wild guess that I should install the thread safe version with laravel (who knows), and downloaded the zip from here:

However, the zip has no readme or install instructions. nor does the website.

Also there is no installer or MSI

i am amazed. No installer, and no installation instructions on php website, nor laravel website.

I would guess you have to add the php directory to the path, but i also saw something about setting up ini files and setting up libraries and dependencies,

Does anyone know where I can find out how to install php, as well as which version?

In production we may use forge, which I would guess uses nginx and some version of php (thread safe or non). How do we find this out so we can replicate this on windows?

Note, I already have several versions of apache installed, and dont want another one with a WAMP installer which will add duplicate mysql, apache etc. which would get very confusing.

nutmix left a reply on Which Version Of Php To Install With Windows - Threadsafe Or Non Threadsafe, And Which Version? • 1 year ago

As an addition, i am assuming I will need to setup a web server and point this to the laravel public dir. If I install apache, I assume I cant use php I would install manually - it may come with its own version.

In this case, I am guessing nginx under windows might be better as it can use the standard PHP through fast-cgi?

nutmix started a new conversation Which Version Of Php To Install With Windows - Threadsafe Or Non Threadsafe, And Which Version? • 1 year ago

I want to install laravel, but hit the first big hurdle - it assumes you already have php, and gives no guidance on which version is suitable.

Which should I install, 5.6 or 7.1.9? which version should I use, thread safe or non thread safe?

I am a grails guru who has been given a laravel 5.3 project to maintain, so now I have no experience with it beyond reading a laravel book from cover to cover (which did not cover php version)

I have heard of homestead, but don't want the pain of virtual machines (with associated file copying, SSH keys, setting up bridged networking (or not), copying files between them, sshing in) and all that jazz. I just want to edit code and see it work.

I got the laravel project to work on a shared hosting (which was a challenge), but this already had php (5.6) installed.

10th August, 2017

nutmix left a reply on Deploying Laravel 5.1 On Vidahost • 1 year ago

How did you solve this? I am using vidahost, but have had no luck in running composer. Even if I do this:

$ /usr/bin/php-5.6-cli composer

i still get the dreaded "unexpected 'class' (T_CLASS)"

I also tried putting "alias php=/usr/bin/php-5.6-cli" in the .bashrc and running it via ". .bashrc" but get same error. By default php is sym linked to php-5.4. Somewhere in the bowels of composer, it is using the old version. No luck yet.

Edit Your Profile

Want to change your profile photo? We pull from