chrismay

chrismay

Member Since 2 Years Ago

Experience Points
30,200
Total
Experience

4,800 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
298
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.

Level 7
30,200 XP
Nov
05
1 week ago
Activity icon

Started a new Conversation Multiple Queues With Different Retry_after Settings

I have jobs in my queue that may take up to several hours (e.g. processing a large csv file) I therefore needed to set the retry_after value to the longest expected time. However I would like to have my faster jobs retry earlier (e.g. after 10 min) I could only set separte values for the timeout in horizon:

'dispatched-jobs' => [ 'connection' => 'redis', 'queue' => Queues::dispatched(), 'balance' => 'auto', 'processes' => Queues::getRequiredProcessCount(Queues::dispatched()), 'tries' => 1, 'timeout' => 5 * 60 ],

'continuous-jobs' => [
    'connection' => 'redis',
    'queue' => Queues::continuous(),
    'balance' => 'auto',
    'processes' => Queues::getRequiredProcessCount(Queues::continuous()),
    'tries' => 1,
    'timeout' => 5 * 60
],

'slow-jobs' => [
    'connection' => 'redis',
    'queue' => Queues::slow(),
    'balance' => 'auto',
    'processes' => Queues::getRequiredProcessCount(Queues::slow()),
    'tries' => 1,
    'timeout' => 23 * 60 * 60
]

Is there also some way to have different values for retry_after?

Sep
09
2 months ago
Activity icon

Started a new Conversation Aspectmock Class Eloquent Was Not Found By Locator

I have installed aspectmock and codeception, but I get InvalidArgumentException : Class Eloquent was not found by locator when I try to use it in my tests.

My tests/bootstrap.php:

require_once  __DIR__.'/../bootstrap/app.php';
require_once  __DIR__.'/../vendor/autoload.php';

$kernel = \AspectMock\Kernel::getInstance();

$kernel->init([
    'debug' => true,
    'cacheDir' => __DIR__ . '/_tmp/aspectMock/cache',
    'includePaths' => [
        __DIR__ . '/../vendor/laravel',
        __DIR__ . '/../app'
    ],
    'excludePaths' => [
        __DIR__,
    ]
]);

$kernel->loadFile(__DIR__.'/../bootstrap/app.php');
$kernel->loadFile(__DIR__.'/../vendor/autoload.php');

Is the bootstrap code wrong?

codeception.yml

paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
bootstrap: bootstrap.php
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed

coverage:
    enabled: true
    include:
        - app/*
Sep
03
2 months ago
Activity icon

Replied to Auto Retry DB Queries

ok I found the solution for anyone interested: This in composer.json replaces the file. Don't forge to run dump-autoload.

"classmap": [
  "vendorOverrides/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php"
],
"exclude-from-classmap": [
  "vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php"
],
Activity icon

Replied to Auto Retry DB Queries

Ok, I found a solution by changing a vendor file: vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php

before:

    public function execute($params = null)
    {
        try {
            return parent::execute($params);
        } catch (\PDOException $exception) {
            throw new PDOException($exception);
        }
    }

after:

 public function execute($params = null)
    {
        $tries = 1;
        $maxTries = 3;
        while(true) {
            try {
                return parent::execute($params);
            } catch (\PDOException $exception) {
                if($tries >= $maxTries)
                    throw new PDOException($exception);
                $tries++;
            }
        }
    }

However I am not sure how to implement this change in my own project without forking the package and the requiring the changed version (I would like to stick to the vendor package and somehow override just the single method)

Activity icon

Started a new Conversation Auto Retry DB Queries

I am currently victim to gap locks in MySQL: http://thushw.blogspot.com/2010/11/mysql-deadlocks-with-concurrent-inserts.html

Simply retrying could be a solution to my problem. I see that there is a separate parameter on transactions:

DB::transaction(function () { ... }, 5);

However I do not use transactions and the problem occurs with normal INSERT statement.

Is there some easy way to handle this globally? E.g. configure the driver to use retries on all queries?

Otherwise I'd have to wrap all queries like this:

for ($retries = 0; $retries <= MAX_NUM_RETIRES; $retries++) {
    try {
        // run query
    } catch (\Exception $e) {
        continue;
    }
    break;
}
Aug
25
2 months ago
Activity icon

Started a new Conversation Posts View Shows Server Time Instead Of User Time

posted x ago is not adjusted to users local time in posts view

The relative time is correct in laracasts.com/dicuss (it shows 3 minutes ago for my last post), but it displays 6 hours ago when I open the post.

Activity icon

Started a new Conversation Separate Queue For Each Job

I was wondering if there are any drawbacks if I dispatch each jobclass to its own queue.

e.g. App\Jobs\SendWelcomeEmail is dispatched to a App\Jobs\SendWelcomeEmail queue.

I plan to do so since it allows me to manage the queue more easily:

e.g. I could see how many pending entries are there for the App\Jobs\SendWelcomeEmail job by calling: Queue::size('App\Jobs\SendWelcomeEmail');

Another usecase is that I have a scheduled job that runs every minute, but I only everwant a single one of those jobs in the queue. This could easily be achieved by having a separate queue for the job.

I use horizon to manage the queue and the setup looks like this:

class Queues { const DEFAULT = 'default'; const SCHEDULER = 'scheduler'; const PROCESS_RESULTS = ProcessResults::class; const MOVE_PROCESSED_ROWS = MoveProcessedRows::class; const SEND_WELCOME_EMAIL = SendWelcomeEmail::class ...

static function all() { $oClass = new ReflectionClass(get_called_class()); return $oClass->getConstants(); } }

horizon.php

... 'queue' => \App\Enums\Queues::all(), ...

I appreciate any feedback or criticism to this setup.