rhand

rhand

Member Since 2 Years Ago

Experience Points 10,330
Experience Level 3

4,670 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 88
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

11 Sep
5 days ago

rhand left a reply on Laravel Dusk Unable To Locate Element: ...":"body Textarea[name='email']"}

Good to hear it helped someone @bespokews ! I will now further this thread figuring out what has changed since I last ran this test.

rhand left a reply on Laravel Dusk Unable To Locate Element: ...":"body Textarea[name='email']"}

Dusk is installed as latest version now with Chrome Driver that works with current Chrome Browser. Now I can get back to issue

) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body textarea[name='email']"}
  (Session info: headless chrome=77.0.3865.75)
  (Driver info: chromedriver=77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/[email protected]{#442}),platform=Mac OS X 10.14.6 x86_64)

rhand left a reply on Laravel Dusk Unable To Locate Element: ...":"body Textarea[name='email']"}

If you are using Chrome version 77, please download ChromeDriver 77.0.3865.40

And I currently seem to have 76:

Updating Google Chrome
Version 76.0.3809.132 (Official Build) (64-bit)

https://sites.google.com/a/chromium.org/chromedriver/downloads

So will try to fix that too.

rhand left a reply on Laravel Dusk Unable To Locate Element: ...":"body Textarea[name='email']"}

Saw this commit https://github.com/laravel/dusk/commit/1632330df524f5be92ef80c6cac2dee113f9435d .

Some markup is updated on http://chromedriver.chromium.org/home website. which break this function

preg_match('/release:.*?\?path=([\d.]+)/', $home, $matches);

should be on line 170 of vendor/laravel/dusk/src/Console/ChromeDriverCommand.php . No official update yet so just did it manually for now.

Then all good

valet @ MacMini [jasper] $ php artisan dusk:install
Dusk scaffolding installed successfully.
Downloading ChromeDriver binaries...
ChromeDriver binaries successfully installed for version 77.0.3865.40.

Only on test I got

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 77
  (Driver info: chromedriver=77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/[email protected]{#442}),platform=Mac OS X 10.14.6 x86_64)

rhand left a reply on Tweaking Old Migrations

Thanks @ftiersch . Thought they would not be run unless names were changed. So issue with column need must have been before addition - one single new migration we did add - to have the column there and some code not choking on it not being there. I guess I will have to dig deeper there to find out why the column was needed. Just wanted to make sure an old migration could not have been part of it on staging or production. Now it seems they have not so issue must have been with a codebase change.

10 Sep
6 days ago

rhand left a reply on Undo Merged Pull Request And Move It To New Branch

Okay, in the end used the Github pull request merger revert button. After that we were able to work on feature in existing branch we used as base for pull request. All easier than I thought :)

rhand started a new conversation Laravel Dusk Unable To Locate Element: ...":"body Textarea[name='email']"}

Tried a test that I ran succesfully before

valet @ MacMini [jasper] $ php artisan dusk tests/Browser/ExampleTest.php 
PHPUnit 7.5.14 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 4.72 seconds, Memory: 28.00 MB

There was 1 error:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body textarea[name='email']"}
  (Session info: headless chrome=76.0.3809.132)
  (Driver info: chromedriver=76.0.3809.126 (d80a294506b4c9d18015e755cee48f953ddc3f2f-refs/branch-heads/[email protected]{#1024}),platform=Mac OS X 10.14.6 x86_64)

/Users/jasper/code/site.com/valet/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:102
/Users/jasper/code/site.com/valet/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:331
/Users/jasper/code/site.com/valet/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:565
/Users/jasper/code/site.com/valet/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:204
/Users/jasper/code/site.com/valet/vendor/laravel/dusk/src/ElementResolver.php:362
/Users/jasper/code/site.com/valet/vendor/laravel/dusk/src/ElementResolver.php:340
/Users/jasper/code/site.com/valet/vendor/laravel/dusk/src/ElementResolver.php:89
/Users/jasper/code/site.com/valet/vendor/laravel/dusk/src/Concerns/InteractsWithElements.php:142
/Users/jasper/code/site.com/valet/tests/Browser/ExampleTest.php:27
/Users/jasper/code/site.com/valet/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:67
/Users/jasper/code/site.com/valet/tests/Browser/ExampleTest.php:33

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Thought perhaps I need to install things for Dusk once more on the new branch and then I had this error:

php artisan dusk:install
Dusk scaffolding installed successfully.
Downloading ChromeDriver binaries...

   ErrorException  : Undefined offset: 1

  at /Users/jasper/code/site.com/valet/vendor/laravel/dusk/src/Console/ChromeDriverCommand.php:172
    168|         $home = $this->getUrl($this->homeUrl);
    169| 
    170|         preg_match('/Latest stable release:.*?\?path=([\d.]+)/', $home, $matches);
    171| 
  > 172|         return $matches[1];
    173|     }
    174| 
    175|     /**
    176|      * Download the ChromeDriver archive.

Not sure if ErrorException : Undefined offset: 1 was a real issue or whether I needed Dusk again in the first place but the error Unable to locate element: {"method":"css selector","selector":"body textarea[name='email']"}

Any ideas?

rhand started a new conversation Undo Merged Pull Request And Move It To New Branch

If I would like to undo a certain pull request I can do this in Github with the revert button. It will then create a revert pull request to undo the merger. Will the branch stuff was merged from then still be as it was?

This so the developer can work on it some more and do a new pull request. Just wandering and do not want to remove work done. Just want to keep it out of master a little longer.

rhand started a new conversation Tweaking Old Migrations

We had migrations tweaked so locally we could once again run these and set up a basic database. We are now trying to figure out where a query need for a column came from and we have not figured it out. Once updated migration did add the column with $table->integer('grid_id')->unsigned();..

Questions I have on Laravel Migrations:

  1. Though old tweaked migrations would work locally from scratch, it would not work on existing setups, right?
  2. Will old migration files run on staging or production again? If no, will they still not be run when you say yes to running migrations on production?
  3. Would you fix migrations to make them work again locally with changing old migrations or would you just add new ones patching old issues (we have quite a few already..)
02 Sep
2 weeks ago

rhand left a reply on Migration Only Adds First Item Of Array

Yeah, @munazzil is not really helping here. He needs to read properly before he replies. Any feedback is welcome, as long as it is on point..

31 Aug
2 weeks ago

rhand left a reply on Migration Only Adds First Item Of Array

We do have the role model Role.php:

<?php

namespace App\Models\Auth;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    public $timestamps = false;

    public function users()
    {
        return $this->hasMany(User::class);
    }
}

as well as a user model under our Models/Auth directory. In User.php we connect things between roles and the users as well using:

  /**
  * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
  */
  public function role()
  {
       return $this->belongsTo(Role::class);
  }

besides other things like user groups.

Anyways, the issue is that somehow migrations do not always run properly - not all roles added to roles table - though there are no errors. Even ran php migrate -vvv but nothing useful showed up when only one role was added.

30 Aug
2 weeks ago

rhand left a reply on Migration Only Adds First Item Of Array

This is weird. I just ran the migrations for the gazillionth time. And now all roles are added to my local Homebrew MariaDB database. Just weird..

rhand left a reply on Migration Only Adds First Item Of Array

That did not work and caused

 Illuminate\Database\QueryException  : SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: insert into `roles` (`0`, `1`, `2`) values (administrator, editor, super-administrator))

  at /Users/me/code/site.com/valet/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664

rhand left a reply on Migration Only Adds First Item Of Array

Hmm, weird. Will have to see if my local MariaDB database settings are the issue @snapey . Still getting only the first row.

@janosk the migrations just ran fine. Will also have to see if migrations after cause the two second lines / roles to be removed. Must be overlooking something here.

29 Aug
2 weeks ago

rhand left a reply on Migration Only Adds First Item Of Array

We're just using short array syntax here as possible since PHP 5.4 https://www.php.net/manual/en/migration54.new-features.php . So do not think that is the issue here. But will look into it.

rhand started a new conversation Migration Only Adds First Item Of Array

I am using this migration on Laravel 5.8.31 to add a table roles with three roles but somehow only the first one is added and the second two are not.

public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
        });

        DB::table('roles')->insert(
            [
                ['name' => 'administrator'],
                ['name' => 'editor'],
                ['name' => 'super-administrator'],
            ]
        );

Any ideas why this could be the case?

27 Jul
1 month ago

rhand commented on Using Recipes For Common Tasks

Servers for Hackers https://serversforhackers.com/scaling-laravel/forge/forge-recipes has really nice recipes to use. Missed sources for useful recipes in this episode so decided to add one.

23 Apr
4 months ago

rhand left a reply on PHP OpCache CACHE_DRIVER / APC

Mohammed Said at Forge explained in Ubuntu (LEMP?) OpCache is always turned on by default, but Forge allows turning on optimized OpCache for production. The difference between the two I do not know yet, but I will figure out.

rhand left a reply on PHP OpCache CACHE_DRIVER / APC

Seems Laravel allows caching of PHP queries and database queries using file, database (database table), memcached or redis. For this you can use specific functions. PHP OpCache pre compiling of scripts is a separate thing altogether.

rhand started a new conversation PHP OpCache CACHE_DRIVER / APC

We are currently using CACHE_DRIVER=file in our .env which means we are using the Laravel Default Caching. We also have PHP Opcache up:

[email protected]:~/domain.com/current$ php artisan opcache:status
General:
+---------------------+-------+
| key                 | value |
+---------------------+-------+
| opcache_enabled     | 1     |
| cache_full          |       |
| restart_pending     |       |
| restart_in_progress |       |
+---------------------+-------+

Memory usage:
+---------------------------+-----------+
| key                       | value     |
+---------------------------+-----------+
| used_memory               | 25.39 MB  |
| free_memory               | 102.61 MB |
| wasted_memory             | 0.00 MB   |
| current_wasted_percentage | 0         |
+---------------------------+-----------+

Interned strings usage:
+-------------------+---------+
| key               | value   |
+-------------------+---------+
| buffer_size       | 8.00 MB |
| used_memory       | 2.14 MB |
| free_memory       | 5.86 MB |
| number_of_strings | 35473   |
+-------------------+---------+

Statistics:
+----------------------+---------------------+
| option               | value               |
+----------------------+---------------------+
| num_cached_scripts   | 555                 |
| num_cached_keys      | 1058                |
| max_cached_keys      | 16229               |
| hits                 | 39858               |
| start_time           | 2019-04-23 05:39:41 |
| last_restart_time    | 1970-01-01 01:00:00 |
| oom_restarts         | 0                   |
| hash_restarts        | 0                   |
| manual_restarts      | 0                   |
| misses               | 565                 |
| blacklist_misses     | 0                   |
| blacklist_miss_ratio | 0                   |
| opcache_hit_rate     | 98.602280879697     |
+----------------------+---------------------+

Funnily enough Forge states it is not active in its Dashboard.. Odd.

Will Bytecode precompiling with OpCache take place with CACHE_DRIVER=file? Will it work either way?

25 Mar
5 months ago

rhand left a reply on DB:raw,selectraw Are They The Same?

Seems that with DB::raw you also have a MySQL injection risk to deal with

Raw statements will be injected into the query as strings, so you should be extremely careful to not create SQL injection vulnerabilities.

Also see https://laravel.com/docs/master/queries#raw-expressions

15 Jan
8 months ago

rhand left a reply on Envoyer With Docker

I am also interested in using Envoyer or Deployer to deploy to a Laradock Docker setup. Main issue always is that you need to run PHP type of commands inside the container, not the host (Ubuntu Droplet in my case).

12 Dec
9 months ago

rhand left a reply on What Is The Difference Between Gates And Policies?

@SOKADA - Thanks for the reference. Good article on Gates, Policies and middleware can. And with a database option mentioned called Bouncer

08 Oct
11 months ago

rhand left a reply on Mix With ProcessCssUrls Enabled Won't Work With Mix.styles()

I was looking into mix.styles to combine some Dashboard CSS styles:

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<link href="/libs/jquery-ui.min.css" rel="stylesheet" />
<link href="/libs/jquery-ui.structure.min.css" rel="stylesheet" />
<link href="/libs/jquery-ui.theme.min.css" rel="stylesheet" />

This for development and production. But here I read image urls are not changing to images being copied. May not be an issue for me working with the mentioned CSS files, but still. Any news on this?

22 Sep
11 months ago

rhand left a reply on How To Use Environment Variables From Laravel In Vue

I did add MIX_PUBLISH_APP_URL=laravel.test to .env. Then I did a art config:clearpost npm run dev.

But the variable added to data publishAppUrl: process.env.MIX_PUBLISH_APP_URLin Vue component still loads nothing in <a :href="'//' + project.stuff + '.' + publishAppUrl" Keep on getting undefined.

04 Aug
1 year ago

rhand left a reply on Queues Max Attempts Exceeded Exception

The example mentioned there is quite good:

<?php

namespace App\Jobs;

class ProcessPodcast implements ShouldQueue
{
    /**
     * The number of times the job may be attempted.
     *
     * @var int
     */
    public $tries = 5;
}

Thanks for mentioning the link @adrian.nuernberger . Will check the code and see how we can adjust it.

rhand left a reply on Redis Queues Management

Yeah, got pretty far learning things and am writing about it here. Once I have figured out removing a single key I will post it here as well.

rhand started a new conversation Queues Max Attempts Exceeded Exception

Having a queue Max Attempts Exceeded Exception issue. It is displayed in Horizon on running an SSL Certificate Update. The error is:

Illuminate\Queue\MaxAttemptsExceededException: Imagewize\SslManager\Jobs\UpdateCertificate has been attempted too many times or run too long. The job may have previously timed out. in /home/forge/domain.com/releases/2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:394

On that line is:

$this->failJob($connectionName, $job, $e = new MaxAttemptsExceededException(
            $job->resolveName().' has been attempted too many times or run too long. The job may have previously timed out.'
        ));

and the config/queue.php retry_after is default 90 seconds..

Any ideas how I can tweak max attempts? Two, any ideas how to echo the attempts made?

rhand left a reply on Redis Queues Management

Thanks @bobbybouwmann . This command would flush all I assume. Any tips on flushing individual jobs?

01 Aug
1 year ago

rhand left a reply on Redis Queues Management

How do I remove queues - failed jobs in particular - from Redis now that it is not possible via Horizon @bobbybouwmann

31 Jul
1 year ago

rhand left a reply on Redis Queues Management

Well, in an ideal world no jobs fail. But when you are testing and a certain command run does not work, and that happens a few times, then it would be nice to remove it to keep it all clean. In Horizon that is or using a command for that matter. Even though failed jobs are removed after seven days.

rhand started a new conversation Redis Queues Management

We have queues in Redis. The command php artisan queue:flush tries mysql database tables but none are there so it fails. So I could change the database driver, add config under database.php connections and make it redis .

But I am told there is no support for failed jobs /jobs there with redis. How do you manage redis queues then?

30 Jul
1 year ago

rhand left a reply on Unsupported Driver [redis]

Yeah, well, but how can you efficiently manage queues in redis? Commands like php artisan queue:flush expect a database table with data, but if you run your queues with --redis they won't be there..

27 Jul
1 year ago

rhand started a new conversation Show Debug Information In Laravel Command Feedback

I am working on a command to update a Let's Encrypt certificate. It keeps on returning no proper a name found (one of the checks to make sure domain was generated before Let's Encrypt certificate is added. Here are the functions dealing with it


namespace Imagewize\SslManager\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Imagewize\SslManager\Core\DnsService;
use Imagewize\SslManager\Core\SslService;
use LogicException;

class UpdateCertificate implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * @var int
     */
    public $tries = 3;

    /**
     * @var string
     */
    private $domain;

    /**
     * Create a new job instance.
     *
     * @param string $domain
     */
    public function __construct($domain)
    {
        $this->domain = $domain;
    }

    /**
     * Execute the job.
     *
     * @param SslService $sslService
     *
     * @param DnsService $dnsService
     * @return void
     */
    public function handle(SslService $sslService, DnsService $dnsService)
    {
        if (!$dnsService->hasProperRecord($this->domain)) {
            $this->fail(
                new LogicException(sprintf(
                    'Domain "%s" must have proper A NAME record."',
                    $this->domain
                ))
            );

            return;
        }

        $sslService->updateCertificate($this->domain);
    }
}

As it keep on returning the exception that all failed I was wondering how I can make the message more specific so I can debug things. Ideas?

23 Jul
1 year ago

rhand left a reply on Custom Artisan Command Not Found

I think I see an issue. For that command the file with the command details is loading this

/**
     * Create a new command instance.
     */
    public function __construct()
    {
        parent::__construct();
    }

The command instance is not being injected with code using type hinting nor is set to store an action into a variable...

rhand left a reply on Custom Artisan Command Not Found

-vvv does not seem to work either. Not sure how I could make that work for a custom command. Debugging seems to be an issue now.Trying to contact the developer as well. Package is currently private, but may make it public at a later stage.

22 Jul
1 year ago

rhand started a new conversation Custom Artisan Command Not Found

I have two custom commands ( see https://laravel.com/docs/5.6/artisan#writing-commands on it all ) in a Laravel package made by a third party. One works, but has issues I will not get into now.

Both of them show when I do a artisan list . I do not see them in app/Console/Commands But I assume is because the commands are loaded by the package, not by using make:command.

But when I execute one of them it it states command not found. How is this possible when it is listed under commands?

rhand left a reply on Forge Let's Encrypt SSL 403 Error

Issue solved. Did not load the challenge directory properly as setup by Forge.

09 Jul
1 year ago

rhand left a reply on Forge Let's Encrypt SSL 403 Error

I fixed the first SSL error [emerg] 2585#2585: no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/my.app.com:4, but still getting a 403

rhand started a new conversation Forge Let's Encrypt SSL 403 Error

Trying to add a Let's Encrypt SSL certificate for a domain and it fails doing the challenge:

--2018-07-09 12:34:12--  https://forge-certificates.laravel.com/le/xxxxxx/565125?env=production
Resolving forge-certificates.laravel.com (forge-certificates.laravel.com)... 104.25.9.32, 104.25.8.32, 2400:cb00:2048:1::6819:820, ...
Connecting to forge-certificates.laravel.com (forge-certificates.laravel.com)|104.25.9.32|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘letsencrypt_script1531139652’

     0K ..                                                     23.2M=0s

2018-07-09 12:34:12 (23.2 MB/s) - ‘letsencrypt_script1531139652’ saved [2344]

Cloning into 'letsencrypt1531139652'...
ERROR: Challenge is invalid! (returned: invalid) (result: {
  "type": "http-01",
  "status": "invalid",
  "error": {
    "type": "urn:ietf:params:acme:error:unauthorized",
    "detail": "Invalid response from http://domain.de/.well-known/acme-challenge/mg3pZtSQZAND0ver1ZmAZfIQb_-lDHvhfpnpGsHvoFs: \"\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003edomain\u003c/title\u003e\n    \u003cmeta name=\"viewport\" content=\"",
    "status": 403
  },
  "url": "https://acme-v02.api.letsencrypt.org/acme/challenge/fI23nBLAfCFJTmkUvGDcuIt0q32cqlZWssTGnvl7Wpc/5555735346",
  "token": "mg3pZtSQZAND0ver1ZmAZfIQb_-lDHvhfpnpGsHvoFs",
  "validationRecord": [
    {
      "url": "http://domain.de/.well-known/acme-challenge/mg3pZtSQZAND0ver1ZmAZfIQb_-lDHvhfpnpGsHvoFs",
      "hostname": "domain.de",
      "port": "80",
      "addressesResolved": [
        "xxx.xxx.xxxxxx",
        "xxxx:xxx:xxxx:xxx::1"
      ],
      "addressUsed": "xxx.xxx.xxx.xxx",
      "addressesTried": [
        "xxxx:xxx:xxxx:xxx::1"
      ]
    }
  ]
})

curl -ikL http://domain.de/.well-known/acme-challenge/mg3pZtSQZAND0ver1ZmAZfIQb_-lDHvhfpnpGsHvoFs does work and resolves to a 200

Also saw these errors

2018/07/08 13:33:44 [emerg] 2585#2585: no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/my.app.com:4
2018/07/08 13:35:01 [notice] 2994#2994: signal process started
2018/07/08 13:35:23 [error] 2999#2999: *30 directory index of "/home/forge/my.app.com/current/public/" is forbidden, client: xx.1xxx.xx.xx, server: , request: "GET / HTTP/1.1", host: "app.de"

Domain folder only accessible by owner drwx (forge) not sure if that matters..

Ideas how to bypass this?

rhand left a reply on Store Unsplash Image Based On Axios.get Request

Something with file_get_contents and file_put-contents got me further again

$file =  $request->request->get('results');
        $current = file_get_contents($file);
        $this->uploadedFile = $current;
        $this->location = '/uploads/' . $this->currentProject->id . '/';
        $this->uploadDir = public_path() . $this->location;
        $current = file_put_contents($this->uploadDir . "boe2", $current);
03 Jul
1 year ago

rhand left a reply on Troubles With Forge Load Balancer

So @devinfd what has your experience been so far?

24 Jun
1 year ago

rhand left a reply on Axios.get Then Axios.post To Store Images From Api On Server

Get requests work based on help here.. So will close this thread. Just need help with server side controller for which I opened another thread.

rhand started a new conversation Store Unsplash Image Based On Axios.get Request

Trying to store data from Axios.get calling images from Unsplash Request here. VueJS side of things can be read about in earlier thread:

[ https://laracasts.com/discuss/channels/javascript/axiosget-then-axiospost-to-store-images-from-api-on-server ](axios get and post from Unsplash API) .

I have the following Axios get request which I use to load data from Unsplash:

saveSearchedUnsplashPhotoToServer : function(result) {
                axios.get(result.urls.full, { results: result.urls.full } )
                .then(this.handleSuccessfulSave)
                .catch(this.catch);
            }, // 204 and 200 status

This grabs the Unsplash image for me. Here example headers

Request URL: https://images.unsplash.com/photo-1431032843361-ec2cd229c751?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjI3NTk2fQ&s=2e8916bb1f05d2eda3b50042b07846fc
Request Method: GET
Status Code: 200  (from disk cache)
Remote Address: 151.101.140.188:443
Referrer Policy: no-referrer-when-downgrade

Now I need a controller to store the image and upload it to a specific directory where I can retrieve it from later. And as you can see no form is used. Just an Axios get request knocking on the Unsplash api door.

Been reading on https://github.com/axios/axios/issues/1195 about using something like:

<?php

$entityBody = file_get_contents('php://input');

file_put_contents(__DIR__ . '/output.txt', print_r(json_decode($entityBody), true));

But I am not quite sure about it yet as they base it on an axios.post request:

axios = require('axios');

var param = {
   args: {
      myStringVal: '979251e4-6c9f-460d-ba32-1b6fe58ce8a3'
   }
};

axios({
   method: 'post',
   url: 'http://home.test/post.php',
   data: param,
});

And I currently only have the get request cause I am getting it from Unsplash... That besides the fact that file_get_contents('php://input') looks like voodoo to me.

I also tried the following using URLSearchParams (polyfill needed):

saveSearchedUnsplashPhotoToServer : function(result) {
                const params = new URLSearchParams();
                params.append('results', result.urls.full);
                axios({
                    method: 'post',
                    url: '/backend/upload-image',
                    client_id: '111',
                    data: params
                });
            },

but the results seem to be empty as I get an error 500. Though the image form data is

results: https://images.unsplash.com/photo-1510274460854-4b7ad642d3a9?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjI3NTk2fQ&s=9abb8a8983b9c6fb434466522d3af9aa

Laravel does mention this however

Symfony\Component\Debug\Exception\FatalThrowableErrorPOST /backend/upload-image
Call to a member function isValid() on null

referring to my method in progress:

public function uploadUnsplashImage(Request $request)
    {
        //$path = $request->result->store('/editor/upload-image');
        // $request_body = file_get_contents('php://input');
        // file_put_contents(__DIR__ . '/output.txt', print_r(json_decode($entityBody), true));

        if (!$request->file('result')->isValid()) {
            return $this->respondFailedWithError(400, "The file is not uploaded successfully.");
        }
.....

So it still is not getting the file.

Somehow still think I should stick to axios.get with PHP storage anyways. Question is how can I do this?

13 Jun
1 year ago

rhand left a reply on Axios.get Then Axios.post To Store Images From Api On Server

Did some more trials. All error 500. I do not understand how I should add the data really. In the get requests I do. In the axios.post I don't. All these options below have failed. This as I do somehow load data in get request well, but not in post. Destination url is correct and for that route I do have a function.

It is just that no data is loaded. I added result to the function as a parameter as it allowed me to make the get request work. But for the post I need something else it seems..

saveSearchedUnsplashPhotoToServer : function(result) {
                axios.post('/backend/upload-image', {
                file: result.urls.full
                })
            }, 

saveSearchedUnsplashPhotoToServer : function(result) {
    axios.post('/backend/upload-image', {
    result: result.urls.full
    })
},

saveSearchedUnsplashPhotoToServer : function(result) {
    axios.post('/backend/upload-image', {
    results: result.urls.full
    })
}, 

saveSearchedUnsplashPhotoToServer : function(result) {
    axios.post('/backend/upload-image', {
    source: result.urls.full
    })
}, 

saveSearchedUnsplashPhotoToServer : function(result) {
    axios({
        method: 'post',
        url: '/backend/upload-image',
        client_id: '111',
        data: {results: result.urls.full}
        });
}, 

the get request

saveSearchedUnsplashPhotoToServer : function(result) {
                axios.get(result.urls.full, { results: result.urls.full } )
                 .then(this.handleSuccessfulSave)
                 .catch(this.catch);
             }, // 204 and 200 status

worked.

I am thinking that perhaps I will need a new route / controller or method for this

Will leave this thread for a while.

PS Clicked solved by accident. Will move solved to answer that solves it again later on.

12 Jun
1 year ago

rhand left a reply on Axios.get Then Axios.post To Store Images From Api On Server

I did read in the blog post now

or to direct the user downloading the photo to (use the photo.urls.full for that instead). The download_location is not to be used to embed the photo (use the photo.urls.* properties instead) or to direct the user downloading the photo to (use the photo.urls.full for that instead).

So perhaps I need to trigger it for views in the modal and preview and even for downloads just so authors get that registered on Unsplash, but the real downloads need to be done with a different one photo.urls.full

rhand left a reply on Axios.get Then Axios.post To Store Images From Api On Server

I get these headers:

Request URL: https://api.unsplash.com/photos/KEPISdOJhxk/download?client_id=11111&responseType=json
Request Method: GET
Status Code: 200 
Remote Address: 151.101.141.181:443
Referrer Policy: no-referrer-when-downgrade
accept-ranges: bytes
access-control-allow-credentials: true
access-control-allow-headers: *
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: http://laravel.test
access-control-expose-headers: Link, X-Total, X-Per-Page, X-RateLimit-Limit, X-RateLimit-Remaining
access-control-max-age: 1728000
access-control-request-method: *

or this response

{"url":"https://images.unsplash.com/photo-1519612535780-b5d7d96c36f3?ixlib=rb-0.3.5\u0026q=85\u0026fm=jpg\u0026crop=entropy\u0026cs=srgb\u0026s=42c89d2eae581ba0fe58dcd0ce90ab12"}

using

saveSearchedUnsplashPhotoToServer : function(result) {
                var apiLink = result.links.download_location;
                const config = {
                    params: {
                        client_id: '1111',
                        responseType: 'json',
                    }
                }
                axios
                    .get(apiLink, config)
                    console.log(result.links.download_location)
                //.then(this.handleSuccessfulSave)
                //.catch(this.catch);
            },

and console output was https://api.unsplash.com/photos/Mv9hjnEUHR4/download

rhand left a reply on Axios.get Then Axios.post To Store Images From Api On Server

I load Unsplash data this way for search display in Vue for loop:

performSearch: function() {
                console.log(this.searchTerm);
                var link = 'https://api.unsplash.com/search/photos?query=';
                var apiLink = link + this.searchTerm;
                const config = {
                    params: {
                        client_id: '1111',
                    }
                }

                axios
                    .get(apiLink, config)
                    .then(response => {
                    this.results = response.data.results;
                    })
                    .catch(error => {
                    console.log(error);
                    });
            },

I can select these in preview with another loop:

<div class="selected-info-container col-md-3">
                                <div class="selected-info-header">
                                    selected image
                                </div>
                                <div style="width: 100%; height: 100%; overflow: hidden; padding-top: 10px;" v-for="(result, results) in results" :key="results.id" v-if="isActive[result.urls.small]">
                                    <div class="form-group row">
                                        <img :src="result.urls.thumb" />
                                    </div>
                                    <div class="form-group row">
                                        <button class="btn btn-primary pull-right" @click="saveSearchedUnsplashPhotoToServer(result)">save</button>
                                        <!-- <button class="btn btn-primary pull-right" @click="startCrop">crop</button> -->
                                    </div>
                                </div>

Post select I use save to store the image on our server.. Well I want to.

According to https://medium.com/unsplash/unsplash-api-guidelines-triggering-a-download-c39b24e99e02

result.links.download_location

should trigger a download so I am trying to use that. result.links.download_location converts to an image url for downloading via their API. A url of an image selected. But somehow that is not grabbed

rhand left a reply on Axios.get Then Axios.post To Store Images From Api On Server

Just the axios.post

axios.post('/backend/upload-image', {
    source: result.links.download_location
})
.then(this.handleSuccessfulSave)
.catch(this.catch)

does not work resulting in an error 500 Call to a member function isValid() on null and it refers to this line

 if ( !$request->file('file')->isValid() )

And that is probably because no file was downloaded. Seems I do need to get the axios.get and pipe it to the axios.post . Unless this has to do with CSRF..

This:

saveSearchedUnsplashPhotoToServer : function(result) {
                var apiLink = result.links.download_location;
                const config = {
                    params: {
                        client_id: '11111',
                        responseType: 'json',
                    }
                }
                axios
                    .get(apiLink, config)
                .then(
                axios.post('/editor/upload-image', {
                    source: result.links.download_location
                }))
                .then(this.handleSuccessfulSave)
                .catch(this.catch)
            },

resulted in the same error 500 FatalThrowableError Call to a member function isValid() on nul

And 'X-CSRF-TOKEN' : document.querySelector('meta[name="csrf-token"]').getAttribute('content') also got a Cannot read property 'getAttribute' of null

And I doubt I needed it as I have

window.axios = require('axios');

window.axios.defaults.headers.common = {
    'X-CSRF-TOKEN': window.Laravel,
    'X-Requested-With': 'XMLHttpRequest'
};

in bootstrap.js