Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

nutmix

Experience

280

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

21st November, 2017

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

FYI I cant find a series on VS Code. if I go to series: https://laracasts.com/series?curated

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? • 3 weeks 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? • 3 weeks 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? • 3 weeks ago

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

E.g.

$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. • 1 month 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

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException

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

Request URL:http://poop.test.com:8080/public2/posts/reskin/1000/1/savetext
Request Method:POST
Status Code:200 OK
Remote Address:127.0.0.1:8080
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Cache-Control:no-cache, private
Connection:Keep-Alive
Content-Length:4
Content-Type:application/json
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
X-Powered-By:PHP/7.1.10
Request Headers
view source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Content-Length:744
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:XSRF-TOKEN=eyJpdiI6IlpwMTNtWVdabGZrMDJ3RkZwaU96WUE9PSIsInZhbHVlIjoiaFAyOEV6MnBLc0ZVbFVTSnlFYWZJUjNzdVdwXC9vRXVvZWk3STE1dFdrNEc4UkhlSFZSMUI3Z2NZVVZhbHd4eEVpXC9scW1mTDNqZzNhcUlRUkJcL1NoeVE9PSIsIm1hYyI6IjAxOWExODhhNTBhYmU4N2JlZjJmMjE3ZTk0ZWU4NDUyN2E0ODljNDc3NjY3ZjBkMmQwM2M5OTQ0NDc0ZTA4NTgifQ%3D%3D; laravel_session=eyJpdiI6Ink0VnJ5d1diYytBNXdKUk9sRWErOUE9PSIsInZhbHVlIjoiK0tcL3VJU1BZM1QwVU1nbzN0V2ZpUmJoN3V3MmUxTUROMGVoZk16d1VQQnFaNFZcL2E5b2x1RkpaY3h5bWUxXC9BMmpTdGhENDlmRXQzY0REMGNTUDUrSEE9PSIsIm1hYyI6ImQyZDcyYmRlNzQ0MmFmODAxY2QzZjU1NmM5M2E1ZGVkZDcxNmUwNTI0NmNiMmM2N2RmMTIyZDQxZmQ0ZjJiZDIifQ%3D%3D
Host:poop.test.com:8080
Origin:http://poop.test.com:8080
Pragma:no-cache
Referer:http://poop.test.com:8080/public2/posts/reskin/1000/1
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
X-CSRF-TOKEN:XEvPMGZc93ynUCB0J1mvH6Xn3fJTbhlURtGG2HQQ
X-Requested-With:XMLHttpRequest

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

Request URL:https://my.xxx.com/posts/reskin/1000/1/savetext
Request Method:POST
Status Code:404 
Remote Address:139.162.156.61:443
Referrer Policy:no-referrer-when-downgrade
Response Headers
allow:POST
cache-control:no-cache, private
content-encoding:gzip
content-type:text/html; charset=UTF-8
date:Tue, 24 Oct 2017 11:12:30 GMT
server:nginx/1.13.3
status:404
vary:Accept-Encoding
Request Headers
:authority:my.xxxx.com
:method:POST
:path:/posts/reskin/1000/1/savetext
:scheme:https
accept:application/json, text/javascript, */*; q=0.01
accept-encoding:gzip, deflate, br
accept-language:en-GB,en-US;q=0.8,en;q=0.6
cache-control:no-cache
content-length:738
content-type:application/x-www-form-urlencoded; charset=UTF-8
cookie:XSRF-TOKEN=eyJpdiI6IndRXC94bnFOZGdlamFkVTAwYXhHa053PT0iLCJ2YWx1ZSI6Ik5YTzhHN2pzbEJxSWlhWkkxYjdjR0NZeEZYTkZYNUpEcnJPMWFjaEN3N0lDK2g4V3ZmQ1FLN2hBeUprQnFIVFZcL2gwcm1ibnZSOGYwMGFrejRMOFNBdz09IiwibWFjIjoiZmQ3OTUwOWE0MGVjMWZmMTY0MTBhMTM1YzcxNTc4MjM2MjhlNjk5MTE0ZWU2NDA5MzgzYWE4OTU4Y2ZlYWFhOSJ9; laravel_session=eyJpdiI6InVHS3FSUm55bnBORThyemFlZ2N6dkE9PSIsInZhbHVlIjoiaVpJb3NLMkVWQ1JNWTgwa2s2U0FwMEdFek1QYnVtREFYWHpGeDhza1VXXC81XC9YTTF2TEdiaUtcL2U5ZGRCXC80aXB2VWx5UklBSWg5Qmx5NzlYYkM2ZytRPT0iLCJtYWMiOiJhOTIyMjEzZmRjOGNmZTY4MzU5Yzc5OTFhMTgyNTIzNjk0MzAwNDE5OGFkM2NiN2RiNjZiOGRkYzUzNWU0YTk1In0%3D
origin:https://my.xxxx.com
pragma:no-cache
referer:https://my.xxxx.com/posts/reskin/1000/1
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
x-csrf-token:eoe71Ki3gRSaB4VYN4Cm0Yfc3IjokoXfqYDShu2f
x-requested-with:XMLHttpRequest

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;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/my.xxxxx.com/server/*;

    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/my.xxxx.com-error.log error;

    error_page 404 /index.php;
    :

nutmix left a reply on Nginx Returns 405 (Method Not Allowed) For PUT Or DELETE • 1 month 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 • 1 month 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:

http://www/ourdomain.com/post/reskin/1003/1/savetext

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 • 1 month 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

nginx/1.13.3

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:

http://www.ourdomain.com/games/reskin/1003/1/savetext 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? • 2 months 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: http://windows.php.net/download/

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? • 2 months 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? • 2 months 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 • 4 months 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
Update

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