trogne

trogne

Member Since 2 Years Ago

Experience Points
6,640
Total
Experience

3,360 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
35
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 2
6,640 XP
Oct
12
1 day ago
Activity icon

Replied to Php Artisan Migrate Class Not Found

Ok, sorry guys. Stupidest mistake ever. <?php;.

Komodo IDE didn't point that out.

Thanks

Activity icon

Replied to Php Artisan Migrate Class Not Found

oh... I now have now error starting from the beginning, must be a silly mistake... I'll post back

Activity icon

Replied to Php Artisan Migrate Class Not Found

No syntax errors. Even if empty :

[email protected]:~/codecourse/buildpodcastapp$ php artisan migrate
<?php;
class CreateUsersTable
{
}

In Migrator.php line 448:

  Class 'CreateUsersTable' not found
Activity icon

Replied to Php Artisan Migrate Class Not Found

No, php artisan migrate is supposed to work with lumen too.

Full error :

In Migrator.php line 448:

  Class 'CreateUsersTable' not found

Because there it cannot instantiate the class.

Activity icon

Started a new conversation Php Artisan Migrate Class Not Found

I have a migration file, with "class CreateUsersTable", but php artisan migrate gives me "class not found".

And composer dump-autoload does not help.

I also tried adding a classmap for migration in composer.json :

    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories",
        "database/migrations"
        ],

Does not help either.

File is "2019_10_12_154406_create_users_table.php"

Oct
11
2 days ago
Activity icon

Replied to Homestead Update Confusion

Thank you. I renamed my Homestead folder, and git-cloned the latest stable Homestead. Now running VM with both latest Homestead code and latest Homestead box.

Activity icon

Replied to I Want To Keep Old Homestead

Solved. This is where the machine id is stored on Windows : C:\Users\username\Homestead.vagrant\machines\homestead\virtualbox

Oct
10
3 days ago
Activity icon

Replied to I Want To Keep Old Homestead

If I rename my vm in virtualbox, and do "vagrant up", it will still detect the vm and rename it to what it was before. I want another vm ! How vagrant knows that it wants the VM I just renamed ?

Activity icon

Started a new conversation I Want To Keep Old Homestead

I want to keep old homestead, but even if I rename my vm name, it will overwrite it when I do "vagrant up". How can I have a separate homestead vm ?

Activity icon

Replied to Homestead Update Confusion

Ok thanks! But what if I'd like to have two homestead VMs simultaneously ? Like both 6.4.0 and 8.2.1, and switch back and forth, so that I can rebuilt some old projects on 8.2.1 ?

Activity icon

Replied to Homestead Update Confusion

Even more confusing, C:\Users....vagrant.d\data\machine-index

The "index" file shows : {"version":1,"machines":{"064c39914f2c4a77a351e0ae8f4046ad" ... ,"version":"6.4.0"}}}}}

6.4.0 ?!?

If I do vagrant up 064c39914f2c4a77a351e0ae8f4046ad, it will load my homestead VM.

Maybe it's still 6.4.0 ? How can I know ?

vagrant up : Bringing machine 'homestead-7' up with 'virtualbox' provider... ==> homestead-7: Checking if box 'laravel/homestead' version '8.2.1' is up to date... ...

But after ssh in :

  • Homestead 8.0.0 released! PHP 7.3 is now the default!
  • Settler v7.0.0 released! Make sure you update
  • Need PHP 5.6 or 7.0? Homestead 7.x Settler 6.4.0
Activity icon

Started a new conversation Homestead Update Confusion

I' ve updated homestead to 8.2.1

vagrant box list
    laravel/homestead (virtualbox, 8.2.1)

But I'm very confuse about this :

On vagrant up, it first told me I had to remove my old homestead 6.4 environment and/or box.

So I did vagrant box prune :

        laravel/homestead (virtualbox, 8.2.1)

        Checking for older boxes...
        Box 'laravel/homestead' (v6.4.0) with provider 'virtualbox' appears
        to still be in use by at least one Vagrant environment. Removing
        the box could corrupt the environment. We recommend destroying
        these environments first:

        homestead-7 (ID: 064c39914f2c4a77a351e0ae8f4046ad)

    Are you sure you want to remove this box? [y/N] y

After that, the box is removed here : "C:\Users\patri.vagrant.d\boxes\laravel-VAGRANTSLASH-homestead\6.4.0"

Now vagrant up works and I'm using 8.2.1.

But what happened to the old homestead environment ? It is unchanged ?

What does that means : "We recommend destroying these environments first" ?

It's the homestead folder where the vagrant file is ?

I haven't touched that. Now homestead is updated, the VirtualBox VM folder is the same size as before, but now I'm using the updated homestead 8.2.1 box.

Feb
04
8 months ago
Activity icon

Replied to Proper Way To Override Vendor Config

If using heroku "MemCachier", we need to change the vendor config file.

So it's not possible with lumen on heroku.

This is the default lumen vendor cache config for memcached :

        'memcached' => [
            'driver' => 'memcached',
            'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
            'sasl' => [
                env('MEMCACHED_USERNAME'),
                env('MEMCACHED_PASSWORD'),
            ],
            'options' => [
                // Memcached::OPT_CONNECT_TIMEOUT  => 2000,
            ],
            'servers' => [
                [
                    'host' => env('MEMCACHED_HOST', '127.0.0.1'),
                    'port' => env('MEMCACHED_PORT', 11211),
                    'weight' => 100,
                ],
            ],
        ],

And this is what we need for MemCachier :

'memcached' => [
    'driver' => 'memcached',
    'persistent_id' => 'memcached_pool_id',
    'sasl' => [
        env('MEMCACHIER_USERNAME'),
        env('MEMCACHIER_PASSWORD'),
    ],
    'options' => [
        // some nicer default options
        // - nicer TCP options
        Memcached::OPT_TCP_NODELAY => TRUE,
        Memcached::OPT_NO_BLOCK => FALSE,
        // - timeouts
        Memcached::OPT_CONNECT_TIMEOUT => 2000,    // ms
        Memcached::OPT_POLL_TIMEOUT => 2000,       // ms
        Memcached::OPT_RECV_TIMEOUT => 750 * 1000, // us
        Memcached::OPT_SEND_TIMEOUT => 750 * 1000, // us
        // - better failover
        Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
        Memcached::OPT_LIBKETAMA_COMPATIBLE => TRUE,
        Memcached::OPT_RETRY_TIMEOUT => 2,
        Memcached::OPT_SERVER_FAILURE_LIMIT => 1,
        Memcached::OPT_AUTO_EJECT_HOSTS => TRUE,

    ],
    'servers' => array_map(function($s) {
        $parts = explode(":", $s);
        return [
            'host' => $parts[0],
            'port' => $parts[1],
            'weight' => 100,
        ];
      }, explode(",", env('MEMCACHIER_SERVERS', 'localhost:11211')))
],

See https://www.memcachier.com/documentation/laravel

So it would be only possible if we could override (with Lumen) the memcache config outside of the vendor folder.

Same with MemcacheCloud I guess.

Feb
03
8 months ago
Activity icon

Started a new conversation Proper Way To Override Vendor Config

In Lumen, there's no app/config folder.

So, for a heroku site, when deploying, all changes that was made to vendor config folders will be lost.

Say I want "memcached" to be configured.

There's a "cache.php" under "vendor\laravel\lumen-framework\config".

How to I override "cache.php" ?

I don't think it's by copying the "cache.php" to a new "config" folder under "app/"...

Activity icon

Replied to Heroku Default Cache

oh, ephemeral, I see ! Thanks.

Just tried "CACHE_DATABASE=database" and it works on heroku !

Activity icon

Replied to Heroku Default Cache

How to use memcached on Lumen ?!?

There's instruction for laravel : https://devcenter.heroku.com/articles/laravel-memcache

But Lumen ?

Activity icon

Started a new conversation Heroku Default Cache

Locally I use "CACHE_DRIVER=file", and the cache works fine.

After deploying to heroku, I do get caching, with "Cache::rememberForever" and "Cache::remember".

However I cannot clear the cache.

At heroku side : php artisan cache:clear says "application cache cleared!", but it is not cleared.

Same result whether I use or not, at heroku side, config var "CACHE_DRIVER=file".

What is a simple solution to solve this ?

Feb
01
8 months ago
Activity icon

Replied to Redirect Post Request To Root, To Index.php

This change works ! :

    # location ~ \.php$ { 
    location ~ \.php$|/$ {

Now I can post to "myproject.local", "myproject.local/index.php", ""myproject.local/someroute"

Jan
31
8 months ago
Activity icon

Started a new conversation Redirect Post Request To Root, To Index.php

Because of CORS, I cannot make to root. So I want the request to switch to index.php.

Currently I can make a post request (with cors middelware), to "myproject.local/index.php". But I'd like to remove the "/index.php".

How do I do that ? In .htaccess ? In nginx config ?

Thanks in advance for providing a working example. I'm very confused with .htaccess and nginx conf file.

Activity icon

Replied to Solution To Axios.post Cors Problem

Unbelievable !

Cors is fully working if I post to something else than the root (/) :

$router->post('/something', '[email protected]');

Any idea on what's causing "not allowed" for post request on "/" ?

It's the same with both Alex Garrett and Barryvdh middlewares.

Another interesing thing : I "die" at the first line of "public/index.php".

If I do an "OPTIONS" request to "http://myproject.local/something", the "die" works.

But doing an "OPTIONS" request to "http://myproject.local" : "405 Not Allowed nginx/1.15.5". So it is blocked BEFORE hitting "index.php" (before hitting Lumen app).

So it must be somewhere in nginx config ! but where ?

"OPTIONS" request to "http://myproject.local/index.php" WORKS TOO !!!

So I found that an "OPTIONS" request to "http://myproject.local" works with this change in "/etc/nginx/sites-available/myproject.local" :

    # location ~ \.php$ { 
    location ~ \.php$|/$ {

Now I can post to "myproject.local", "myproject.local/index.php", ""myproject.local/someroute"

Activity icon

Replied to Solution To Axios.post Cors Problem

Interesting test here :

LinkController.php :

    public function testcorsoptions()
    {
        return response('HIT!!!', 200);
    }

TEST 1 : In web.php :

$router->options('/', '[email protected]');

Using Postman :

"OPTIONS" request to http://myproject.local/ :

405 Not Allowed nginx/1.15.5

BUT!!! : TEST 2 :

In web.php :

$router->options('/something', '[email protected]');

Using Postman :

"OPTIONS" request to http://myproject.local/something :

Status 200 OK HIT!!!

So there's something bad about my root "/" !!! What ?

Activity icon

Replied to Solution To Axios.post Cors Problem

@ARTCORE - But I'm on Lumen, so it's different.

What I tried :

In web.php :

$router->options('/', '[email protected]');
$router->post('/', '[email protected]');

In bootstrap/app.php :

 $app->middleware([
     App\Http\Middleware\Cors::class,
 ]);

"handle" method in middleware not hit

"testcorsoptions" method not hit.

Again this in the console : Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://blabla.local/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I also just tried an "OPTIONS" request in postman : I get "405 Not Allowed nginx/1.15.5"

Activity icon

Replied to Solution To Axios.post Cors Problem

I don't have to set the 2 headers using Axios, because I see them in the post request by default :

Access-Control-Request-Headers access-control-allow-origin,content-type

Access-Control-Request-Method POST

Also, CORS works for "axios.get". The problem is just with the "OPTIONS" preflight request.

I'm pretty sure the problem lies on the backend, in Lumen. But the "OPTIONS" request does not even goes at my Cors middleware. If I die at the beginning of the middleware "handle" method, it's not even hit.

Activity icon

Replied to Solution To Axios.post Cors Problem

"provide Access-..." headers, where ?

With axios ? Or In Lumen ?

Before using "HandleCors" I was using this Middleware (by Alex Garrett) :

class Cors
{
    public function handle($request, Closure $next)
    {
        $headers = [
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Methods' => 'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS', 
            'Access-Control-Allow-Headers' => 'Content-Type'
        ];
        
        if ($request->getMethod() === 'OPTIONS') {
            return response(null, 200, $headers);
        }

        $response = $next($request);
        
        foreach ($headers as $key => $value) {
            $response->header($key, $value);
        }
        return $response;
    }
}
Jan
30
8 months ago
Activity icon

Started a new conversation Solution To Axios.post Cors Problem

What is a WORKING solution to the axios.post cors problem ?

I have cors setup in Lumen, with a cors middleware.

In my frontend, when I do "axios.post", I get "Not Allowed" for the preflight OPTIONS request.

I've tried Barryvdh\Cors\HandleCors , still not working.

Where's a working solution for this issue ?

Jan
29
8 months ago
Activity icon

Started a new conversation Change Vue Init Defaults

When running "vue init", like "vue init webpack projectname", there are defaults for the author name, project name, etc.

Where can I change those defaults ? I want to change my default name !

Thanks

Jan
27
8 months ago
Activity icon

Replied to Observer Not Hit

WOW!!! I found how to solve this :

I needed to move "Link::observe" inside a "boot" method in "AppServiceProvider".

    public function boot()
    {
        Link::observe(LinkObserver::class);
    }

Initailly, there was only a "register" method stub in there.

Activity icon

Started a new conversation Observer Not Hit

I have an observer, and it's not hit on update.

In "AppServerProvider.php" :

    public function register()
    {
        die('this is hit');
        Link::observe(LinkObserver::class);
    }

The "die" works here. So I comment this line.

But then I add this "die" in "LinkOberver.php" :

    public function __construct()
    {
        die('HIT');
    }

This "die" is not even hit. Why ?

In LinkController, I have this :

        if (!$link->exists) {
            $link->save();
            //$link->update([  //refactored , moved to model observer
            //    'code' => $link->getCode(),
            //]);
        }

Upon save, the observer created method is not hit.

Jan
22
8 months ago
Activity icon

Replied to Create A Database With Pgadmin

I added my database name in "homestead.yaml", then provision.

Now database is there.

Activity icon

Started a new conversation Create A Database With Pgadmin

I use pgadmin to connect to homestead postgres.

However the option to create a new database is greyed out.

For user "homestead", I see "create databases" set to "NO" in pgadmin properties.

What is the homestead root user for postgres ?

Jan
20
8 months ago
Activity icon

Replied to Laravel - Vue, No Hot Reload

I'm trying without homestead. Just a local laravel project.

After running "npm run hot", if I go to "http://localhost:8080/js/bundle.js", I see "CANNOT GET".

When saving a vue file, I see in the console that it recompiles. But where's the "bundle.js" file ?!?

Jan
18
8 months ago
Activity icon

Replied to Laravel - Vue, No Hot Reload

Thanks but that did not helped..

What I tried :

Added this to webpack.mix.js :

mix.options({
    hmrOptions: {
        host: 'localhost',
        port: '9000'
    }
}

Added "--port 9000" to package.json :

"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js --port 9000",

Replaced the link in welcome.blade.php :

 <script src="http://localhost:9000/js/app.js"></script>

My project is on my homestead vm, served on "vuexsingleboiler.local"

If I go to "http://localhost:9000/js/app.js", I get "Cannot GET". Same with "http://localhost:9000/bundle.js". "Cannot GET".

If there's a file in public/js, I can access it using the note server, like http://localhost:8080/js/app.js

But in this case, "app.js" is not a file created by "npm run hot". It it the one created by "npm run watch".

Where is the bundled file created by npm run hot ?

If I access "vuexsingleboiler.local", I see this in the console : "Loading failed for the with source “http://localhost:8080//js/bundle.js”

That's the link resolved by "mix('js/bundle.js')".

Jan
15
8 months ago
Activity icon

Started a new conversation Laravel - Vue, No Hot Reload

Why hot browser reload is not working with a laravel vue installation ?

If I install a fresh vue app, the browser refresh on save with npm run dev.

But with the laravel vue installation, the browser does not refresh, either with npm run dev/watch/watch-poll/hot.

npm run hot does not even create the "public/js/app.js" file.

I'm using windows, with the laravel app on homstead.

Running npm/node on windows as usual.

This is NOT working : https://laracasts.com/discuss/channels/laravel/simple-vue-hot-reload-with-laravel-54-and-mix?page=1

I also manually added a "js" file in "public/js", then started "npm run hot". Changing that js file does not even do hot reload.

Anyone on windows/homesteasd got "npm run hot" working ?

Jan
14
8 months ago
Activity icon

Replied to Laravel And Vue - Popper Error

Not really. I want to fix the problem, not replace it with a 404. Anywayt I get this after the "touch" command : Source map error: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data Resource URL: http://vuexsingleboiler.local/js/app.js Source Map URL: popper.js.map

Activity icon

Started a new conversation Laravel And Vue - Popper Error

Only on firefox console (not in chrome), I see this on a new Laravel/Vue project :

Source map error: request failed with status 404 Resource URL: http://vuexsingleboiler.local/js/app.js Source Map URL: popper.js.map

This thread here does not have a working solution : https://laracasts.com/discuss/channels/elixir/laravel-mix-issue-popperjs-dependency-cannot-be-found-by-boostrap-4-beta

In chrome, I have these errors :

newtab-serviceworker.js:16 Uncaught (in promise) ReferenceError: FILES is not defined at newtab-serviceworker.js:16

Dec
04
10 months ago
Activity icon

Replied to Passing Vue.http Post Data

Great, thank you @koalamo

Dec
03
10 months ago
Activity icon

Started a new conversation Passing Vue.http Post Data

I can add data to an http post request, like this :

    Vue.http.post('auth/signup', {
        email: email,
        username: username,
        password: password
   })

On the backend, the $request is a json string. And use the data with $request->json('fieldname').

Before Vue 2, I was able to add the data in a "data" property, like that :

    Vue.http({
        url: 'auth/signup/',
        method: 'POST',
        data: { email: email, username: username, password: password }
})

But that way, the request on the backend is empty.

Is it possible to use the second approach, with "method: 'POST'" ? Maybe it's not "data:" ? Or there's a header missing ?

Nov
18
10 months ago
Activity icon

Replied to How To Hit The Api Route

Thank you @cronix, I'll check this out someday. Is it covered on a Laracasts course ?

Nov
17
10 months ago
Activity icon

Replied to How To Hit The Api Route

| | GET|HEAD | api/user | | Closure | api,auth:api |

It's a closure, and I'm trying to hit that closure.

Activity icon

Replied to How To Hit The Api Route

Yes, but hitting "api/user" gives me a 404. Api routes cannot be entered in a browser.

What simple test I can do to hit the callback ?

I believe I have to set some headers to authenticate, but how and where ?

Activity icon

Started a new conversation How To Hit The Api Route

In routes, there's a "api.php" file.

How do I hit the callback ?

Route::middleware('auth:api')->get('/user', function (Request $request) {
    die('aaaa');
    return $request->user();
});

How can I see the "aaaa" ?

Nov
09
11 months ago
Activity icon

Replied to Homestead IP

I see ! Of course, if I query the server from my PC, I'm not homestead ! I'm me. And me = 192.168.10.1. Thanks !

Activity icon

Started a new conversation Homestead IP

In my homestead guest, my IP is "192.168.10.10".

But on my host, if I print the user IP, I see "192.168.10.1".

Why not 192.168.10.10 ?

"SERVER_ADDR" => "192.168.10.10" "REMOTE_ADDR" => "192.168.10.1"

Ok, it's "REMOTE_ADDR" that sends the request.

But where can I see "192.168.10.1" in my homestead VM ?

"ip addr" shows of course "192.168.10.10" (the server). But what about 192.168.10.1 ?

Activity icon

Replied to How Does The "Route" Facade Object Can Access Methods Like "auth()" And "prefix()" ?

Oh!! The magic method "__callStatic" in Facade.php !

Activity icon

Started a new conversation How Does The "Route" Facade Object Can Access Methods Like "auth()" And "prefix()" ?

How does the "Route" facade object can access methods like "auth()" and "prefix()" ?

This works :

Route::auth();

But :

var_dump(get_class(new Route)); //Illuminate\Support\Facades\Route
$reflection = new ReflectionClass(new Route);
var_dump( $reflection->getMethods(ReflectionMethod::IS_STATIC ) );
die();

If I "reflect" on a Route facade object instance, and dump the static methods, I do not see the "auth" method.

The Route facade extends Facade. If I don't extend, Laravel will try to reach the "prefix" method. Neither "prefix" nore "auth" is defined in Facade.php.

So, how does the "Route" facade object can access methods like "auth()" and "prefix()" ?

Aug
25
1 year ago
Activity icon

Replied to Blocked From Google Search, And Recaptcha Is Not Showing Up

Sorry for that unusual question.

I was not blocked on other browsers.

Deleting firefox cookies fixed my issue.

Aug
24
1 year ago
Activity icon

Started a new conversation Blocked From Google Search, And Recaptcha Is Not Showing Up

blocked from google search, and recaptcha is not showing up

?!?

So sending a question here, to see if this recaptcha will help, and it doesn't.

Aug
22
1 year ago
Activity icon

Replied to Global Scope Not Working

ok !!! Thread model, I said "withoutGlobalScope('active')" so that I don't read the excluded channels.

But now that my scope is in a class, I have to exclude the class :

return $this->belongsTo(Channel::class)->withoutGlobalScope(\App\Scopes\ChannelScope::class);