Cyber Monday! Get 25% off for as long as you keep your subscription. New subscribers only.

tkhara

tkhara

Member Since 1 Month Ago

Experience Points
1,210
Total
Experience

3,790 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
9
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 1
1,210 XP
Nov
02
4 weeks ago
Activity icon

Commented on Setup A Database Connection

For anyone doing this course and having a tough time setting up a dev environment please consider using containers.

I am on linux, but I guess you can set these up on all platforms.

For linux I just installed docker and docker-compose.

You can follow this thread to see the discussions about using artisan served to set up the whole stack as containers.

There is a config file that needs to be set... I set the following values:

This file is served.php

'php' => [
    'version' => env('SERVED_PHP_VERSION', '7.4'),
    'modules' => [
        'pdo_mysql',
        'zip',
        'bcmath'
    ],
    'npm' => true,
    'xdebug' => [
        'enabled' => true,
        'port' => 9001,
    ],
],
'web' => [
    'service' => 'nginx', //or apache
    'version' => '1.9.2', //apache currently only supports latest!
    'port' => env('SERVED_WEB_PORT', 8095),
    'ssl_port' => env('SERVED_WEB_SSL_PORT', 4443),
],
'extras' => [
    'mysql' => [
        'service' => 'mysql',
        'version' => '5.7',
        'port' => env('SERVED_EXTERNAL_DB_PORT', 33007),
        'root_password' => 'password',
        'database' => env('DB_DATABASE', 'laravel'),
        'username' => env('DB_USERNAME', 'laravel'),
        'password' => env('DB_PASSWORD', 'password'),
    ],
],

Then in your .env file you can set the values like this:

DB_CONNECTION=mysql
DB_HOST=served_blog_mysql	
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=password

You can always run docker ps to see the name for your mysql container.

Thanks,

TJ.

Activity icon

Replied to First Connection To Mysql Database

Hi,

Thank you for taking the time to look into this.

When I connect to mysql from an external client like workbench I am using the 127.0.0.1 and port 33007.

With another gui client like dbeaver even localhost and port 33007 work.

I guess when I connect from a client on my system I am not a part of the same network so I use this externally mapped port to get access to the mysql docker container.

If I inspect the container this is a part of the output:

"Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "GOSU_VERSION=1.12",
            "MYSQL_MAJOR=5.7",
            "MYSQL_VERSION=5.7.31-1debian10",
            "MYSQL_ROOT_PASSWORD=password",
            "MYSQL_DATABASE=laravel",
            "MYSQL_USER=laravel",
            "MYSQL_PASSWORD=password"
        ],

"NetworkSettings": {
        "Bridge": "",
        "SandboxID": "f50adbd884197eed553e1911f83b9ba65726bade24bd88a9da81819f73c2a6ba",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "3306/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "33007"
                }
            ],
            "33060/tcp": null
        },

As I was working through this response I got it... Usually with containers you can just refer to them by their name within the network. I tried that and it worked. I'll leave it here:

DB_CONNECTION=mysql
DB_HOST=served_blog_mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=password

The port on my localsystem in that 33007, but for the running app the port is 3306 as it can connect directly from within that network.

Thank you for helping me troubleshoot.

Regards,

TJ.

Activity icon

Started a new Conversation First Connection To Mysql Database

Hi,

I am having some trouble as i follow this video (this is my first laravel tutorial) @4:48

https://laracasts.com/series/laravel-6-from-scratch/episodes/9?autoplay=true

This is the error I'm seeing:

https://flareapp.io/share/KPgDx9d7

Illuminate\Database\QueryException SQLSTATE[HY000] [2002] Connection refused (SQL: select * from posts where slug = my-second-post limit 1)

I have these in my .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33007
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=password

And I have these for my database setup (using artisan served):

'service' => 'mysql',
     'version' => '5.7',
     'port' => env('SERVED_EXTERNAL_DB_PORT', 33007),
     'root_password' => 'password',
     'database' => env('DB_DATABASE', 'laravel'),
     'username' => env('DB_USERNAME', 'laravel'),
     'password' => env('DB_PASSWORD', 'password'),

Thanks,

TJ.

Activity icon

Commented on Setup A Database Connection

This problem has been solved by @danantonielli 's response above.

Now I am running into this issue:

https://flareapp.io/share/KPgDx9d7

Illuminate\Database\QueryException SQLSTATE[HY000] [2002] Connection refused (SQL: select * from posts where slug = my-second-post limit 1)

I have these in my .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33007
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=password

And I have these for my database setup (using artisan served):

'service' => 'mysql',
     'version' => '5.7',
     'port' => env('SERVED_EXTERNAL_DB_PORT', 33007),
     'root_password' => 'password',
     'database' => env('DB_DATABASE', 'laravel'),
     'username' => env('DB_USERNAME', 'laravel'),
     'password' => env('DB_PASSWORD', 'password'),

Thanks,

TJ.

Activity icon

Commented on Setup A Database Connection

Hi,

I'm having trouble at @4:48 with this line:

$post = .\DB::table('posts')->where('slug', $slug)->first();

My ide gives me an indication that something is off and this is the error that i see:

https://flareapp.io/share/B5Z9JZq7#F35

Any tips to troubleshoot this are appreciated.

Thank you,

TJ.

Activity icon

Commented on Setup A Database Connection

Thank you very much. I've been looking for a decent database gui in linux for a while. dbeaver seems great.

Activity icon

Replied to Setting Custom Php Version For Valet Linux Dev Site

And sorry I couldn't format this better. I still haven't figured out how to get those code blocks in the formatting.

Activity icon

Replied to Setting Custom Php Version For Valet Linux Dev Site

Great thank you.

I'll just put these here as well if someone else reads this. I found these two additional ways to connect via command line.

Connect to mysql container

docker exec -it served_blog_mysql bash

[email protected]:~$ docker exec -it served_blog_mysql bash
[email protected]:/# mysql -u root -p
Enter password: password

Connecting via command line

mysql -h 127.0.0.1 -P 33007 -u root -p laravel

But, this one is quite elegant thank you - php artisan served:ssh mysql

Best,

TJ.

P.S. I just tried running this and go the following output:

[email protected]:~/envs/docker/laravel_served/blog$ php artisan served:ssh served_blog_mysql

Exception

Could not resolve served_blog_mysql

at vendor/sinnbeck/laravel-served/src/ServiceManager.php:154 150▕ if ($config = config('served.extras.' . $name)) { 151▕ return $this->resolve($name, Arr::get($config, 'service'), $config); 152▕ } 153▕ ➜ 154▕ throw new Exception('Could not resolve ' . $name); 155▕ } 156▕ } 157▕

  +14 vendor frames 

15 artisan:37 Illuminate\Foundation\Console\Kernel::handle()

served_blog_mysql is the name of my container and i tried this with the sha as well:

[email protected]:~/envs/docker/laravel_served/blog$ php artisan served:ssh 1aa3491d4b99

Exception

Could not resolve 1aa3491d4b99

at vendor/sinnbeck/laravel-served/src/ServiceManager.php:154 150▕ if ($config = config('served.extras.' . $name)) { 151▕ return $this->resolve($name, Arr::get($config, 'service'), $config); 152▕ } 153▕ ➜ 154▕ throw new Exception('Could not resolve ' . $name); 155▕ } 156▕ } 157▕

  +14 vendor frames 

15 artisan:37 Illuminate\Foundation\Console\Kernel::handle()

This is my docker ps:

1aa3491d4b99 served/blog_mysql "docker-entrypoint.s…" 23 hours ago Up 5 hours 33060/tcp, 0.0.0.0:33007->3306/tcp served_blog_mysql bb809a4f5d0a served/blog_web "nginx -g 'daemon of…" 23 hours ago Up 5 hours 0.0.0.0:8095->80/tcp, 0.0.0.0:4443->443/tcp served_blog_web 69f2bef943d9 served/blog_php "docker-php-entrypoi…" 23 hours ago Up 5 hours 9000/tcp served_blog_php

Am I doing this wrong?

Thanks.

Activity icon

Replied to Setting Custom Php Version For Valet Linux Dev Site

Great. Thank you. Going through these. They are very well made.

Quick question - if I don't want to use a database gui while development what would be the method to access the command line mysql client with in the mysql docker container?

Should I use the shell within the container to run the mysql client?

The reason I ask is because I am on a linux mint system and mysql workbench is really glitchy. I usually try and use the mysql command line or I add another container for phpmyadmin in dev.

So, when using served can I get access to the docker-compose.yml file to add that phpmyadmin container in that file or do I create it separately and then connect it to the network created by served?

Nov
01
4 weeks ago
Activity icon

Replied to Setting Custom Php Version For Valet Linux Dev Site

Thank you. The local environment is up and running... Great job with served. Really beneficial to have this to get a dev environment up and running quickly.

I am new to laravel... could I ask you to recommend a getting started tutorial since I'd really value your input.

There is a lot of information out there, but maybe i can find an up to date on to get me up and running quickly? Preferably one with the latest version of laravel.

Regards,

TJ.

Activity icon

Replied to Setting Custom Php Version For Valet Linux Dev Site

Hi,

Thank you. I did not know about laravel served. That seems like a great idea to get started quickly.

I was trying to set it up and ran into an issue. It would be great if you could give me some direction with it.

Here are the steps I took:

mkdir laravel_served cd laravel_served/ composer require sinnbeck/laravel-served --dev

Then I tried running this command:

php artisan served:up

But, realized I had not created a laravel project yet.

Got this error: Could not open input file: artisan

I then created a laravel project:

composer create-project --prefer-dist laravel/laravel blog

Then went into this new blog directory

cd blog

and did

php artisan served:up

I now get this message:

There are no commands defined in the "served" namespace.

Any tips on how to progress from here and setup the first local stack via containers?

Thank you,

TJ.

Oct
31
4 weeks ago
Activity icon

Replied to Setting Custom Php Version For Valet Linux Dev Site

Thank you... that seems like a great idea. Do you also deploy sites using docker containers or do you provision whole servers? I am just trying to think of an efficient dev to deployment setup...

Activity icon

Started a new Conversation Setting Custom Php Version For Valet Linux Dev Site

Hi,

I just set up valet linux, but was wondering how i could setup custom php settings for each dev project like error reporting on etc.

Thank you,

TJ.