AlexGodbehere

AlexGodbehere

Member Since 2 Years Ago

Experience Points
33,910
Total
Experience

1,090 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
327
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 7
33,910 XP
Feb
23
1 month ago
Activity icon

Replied to Please Make Sure The PHP Redis Extension Is Installed And Enabled.

Ok, additional update. I'm using Redis elsewhere in my application to store the value of when a user was last seen, which is still working well.

use Illuminate\Support\Facades\Redis;

public function getLastSeenAttribute() {
    $redis = Redis::connection();
    return $redis->get('last_seen_'.$this->id);
}

alt text

Activity icon

Replied to Please Make Sure The PHP Redis Extension Is Installed And Enabled.

@philamne, I'm using Valet, but yes I've tried to restart it. The jobs that are causing it to fail are being ran b the scheduler though, if that makes any difference.

Activity icon

Replied to Please Make Sure The PHP Redis Extension Is Installed And Enabled.

Yes, extension_loaded('redis') returns true when placed at the top of routes/web.php.

Activity icon

Replied to Please Make Sure The PHP Redis Extension Is Installed And Enabled.

Thanks, but I'm using phpredis not predis.

Activity icon

Replied to Please Make Sure The PHP Redis Extension Is Installed And Enabled.

Same php.ini, confirmed Redis loaded.

Activity icon

Started a new Conversation Please Make Sure The PHP Redis Extension Is Installed And Enabled.

I'm getting spammed with Please make sure the PHP Redis extension is installed and enabled. in my logs, despite having the redis.so extension installed on MacOS. I installed the Redis extension by running pecl install redis, which succeeds with the following message:

Installing '/usr/local/Cellar/php/7.3.12/pecl/20180731/redis.so'
install ok: channel://pecl.php.net/redis-5.1.1
Extension redis enabled in php.ini

By running phpinfo() in tinker, I can see that my loaded php.ini is

Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini

If I open up /usr/local/etc/php/7.3/php.ini, extension="redis.so" is listed at the top of the file.

What makes this more and more strange is that if I dig deeper into where the original Please make sure the PHP Redis extension is installed and enabled. error is coming from, it looks to be in laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:76, which looks like this:

throw new LogicException(extension_loaded('redis') ? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'  : 'Please make sure the PHP Redis extension is installed and enabled.');

So according to this, the extension isn't loaded. But if I load up tinker again and run extension_loaded('redis') then I get a true result.

I can't for the life of me figure out what's going on here. Why does PhpRedisConnector not see that the extension is loaded?

For completeness, I've also removed the Redis alias from my app.php file as instructed to by the Laravel docs.

Feb
10
1 month ago
Activity icon

Replied to Getting `read Error On Connection` When Trying To Use DigitalOcean Managed Redis

Couldn't see it. I asked on the DO forums and it was suggested.

Activity icon

Awarded Best Reply on Getting `read Error On Connection` When Trying To Use DigitalOcean Managed Redis

Thanks @bobbybouwmann. Appending tls:// to the URL did the trick!

Feb
09
1 month ago
Activity icon

Started a new Conversation Getting `read Error On Connection` When Trying To Use DigitalOcean Managed Redis

I'm looking to scale my application from a single server to multiple, so I've set up a brand new Redis managed database on DigitalOcean. After trying to point my Laravel app to use it I'm getting a read error on connection error. Having scouted around the internet for the best part of a day, I've realised that it doesn't seem to be a common issue. I'm running Laravel 6.2, phpredis 5.1.1 and php 7.3.13. I've allowed my droplet to access the Redis instance over private networking.

Error

My config/database looks like this:

'redis' => [

            'client'  => 'phpredis',
            'cluster' => false,

            'default' => [
                'scheme'   => 'tls',
                'host'     => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', null),
                'port'     => env('REDIS_PORT', 6379),
                'database' => env('REDIS_DB', 0),
            ],

            'cache'   => [
                'scheme'   => 'tls',
                'host'     => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', null),
                'port'     => env('REDIS_PORT', 6379),
                'database' => env('REDIS_CACHE_DB', 1),
            ],
            'options' => [
                'prefix'     => env('REDIS_PREFIX', Str::slug(env('APP_ENV', 'ENVNOTDEFINED'), '_').'_database_'),
                'parameters' => ['password' => env('REDIS_PASSWORD', null)],
            ],
        ]

And my .env file contains the required values:

REDIS_HOST=DATABASE_URL.db.ondigitalocean.com
REDIS_PASSWORD=PASSWORD
REDIS_PORT=25061

I found this question, but becasue I'm already running later versions than the suggested fix, the answer didn't solve my problem.

Has anyone encountered this before?

Oct
31
4 months ago
Activity icon

Replied to Repeatably Accessing Attribute From Blade Resulting In Additional Database Queries

So I wouldnt access $this->flights() from the model?

Activity icon

Replied to Repeatably Accessing Attribute From Blade Resulting In Additional Database Queries

Is there a reason that you've accessed Flight directly rather than $this->flights()?

Activity icon

Replied to Repeatably Accessing Attribute From Blade Resulting In Additional Database Queries

Confirmed. Returning null removes the queries. Is there a way that I can cache this value?

Activity icon

Replied to Repeatably Accessing Attribute From Blade Resulting In Additional Database Queries

I am actually hitting a relationship in this. Could that be the issue?

/**
         *    Gets the current flight
         */
        public function getCurrentFlightAttribute () {

            return $this->flights()->with(
                'aircraft')->where('arrival_time', null)->first();
        }
Activity icon

Started a new Conversation Repeatably Accessing Attribute From Blade Resulting In Additional Database Queries

I've got a blade component that is passed a model via route model binding. Every time I access an attribute on the model I'm making additional database requests. Does blade not cache the object? Example, the first code block executes 3 queries, and the second code block executes 12 (9 of which are duplicated). Am I missing something here?

My model has the 'attribute' in the appends[] array.

@if ($model->attribute !== null)
        ... Logic
@endif
@if ($model->attribute !== null)
        ... Logic
@endif
@if ($model->attribute !== null)
        ... Logic
@endif
@if ($model->attribute !== null)
        ... Logic
@endif
@if ($model->attribute !== null)
        ... Logic
@endif