skylark's avatar

skylark wrote a comment+100 XP

2w ago

This code is simply beautiful!. But, is it still a beginner level? I wonder what advanced patterns look like.

skylark's avatar

skylark wrote a comment+100 XP

4w ago

@jeffreyway The weirdest bug ever - it may tickle your curiosity.

The bug came into existence after this massive refactoring here. Before, with the same router.php and same routes.php, all was fine and dandy, but it may not be related to it.

The route '/notes' broke.

When I typed this path in the URL or triggered it from the navigation, I was redirected to the public (page not found).

'/note' or 'notes/create' were working (as all the simple routes: home, about, contact) - this told me the issue was not in the DB connection.

Retyping routes.php did not fix the bug.

I came up with a workaround by simply renaming the faulty route '/notes_all' (other names were fine too: notess, nnotes, allnotes...

Maybe there is a conflict with some variable, but I am just guessing.

skylark's avatar

skylark wrote a comment+100 XP

1mo ago

For XAMPP/LAMPP users (Ubuntu) who are lost in the sweeping changes during the Autoloading episode.

  1. I modified httpd.conf:

DocumentRoot "/opt/lampp/htdocs/name_of_your_app/public" <Directory "/opt/lampp/htdocs/name_of_your_app/public">

  1. I moved .htaccess to the public folder together with index.php; my .htaccess file below, no changes from earlier:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*$ index.php [L]

skylark's avatar

skylark wrote a comment+100 XP

2mos ago

@lara324508 Thanks! It worked. Just a minor hiccup, the XAMPP dashboard degraded to the default HTML.

skylark's avatar

skylark liked a comment+100 XP

2mos ago

@Krishna-Clarke If you're using XAMPP on Ubuntu (Linux), you need to do the following:

By default, XAMPP uses /opt/lampp/htdocs as the root directory.
This can be changed by modifying the Apache configuration file located at:

/opt/lampp/etc/httpd.conf

In that file, you’ll find the default configuration:

DocumentRoot "/opt/lampp/htdocs"
<Directory "/opt/lampp/htdocs">

If you create a folder named /opt/lampp/htdocs/demo, you need to update the configuration as follows:

DocumentRoot "/opt/lampp/htdocs/demo"
<Directory "/opt/lampp/htdocs/demo">

Now, this folder becomes your new root directory, and accessing localhost/ will take you directly into it.


You should also add an .htaccess file to the root folder with the following content:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [L]

This file enables URL rewriting, so that when a user enters a non-existent URL, they are redirected to index.php.

skylark's avatar

skylark liked a comment+100 XP

2mos ago

I use XAMPP on Ubuntu, and I’m completely satisfied with phpMyAdmin for database management.

skylark's avatar

skylark liked a comment+100 XP

2mos ago

Since I’ve noticed that there are many questions about setting up the environment to match the one Jeffrey is using, I’ll write a fresh guide for configuring the XAMPP environment on Ubuntu (Linux).

XAMPP Configuration on Ubuntu (Linux) Operating System

By default, XAMPP uses /opt/lampp/htdocs as the root directory.
This can be changed by modifying the Apache configuration file located at:

/opt/lampp/etc/httpd.conf

In that file, you’ll find the default configuration:

DocumentRoot "/opt/lampp/htdocs"
<Directory "/opt/lampp/htdocs">

If we create a folder /opt/lampp/htdocs/demo, we need to update the configuration to:

DocumentRoot "/opt/lampp/htdocs/demo"
<Directory "/opt/lampp/htdocs/demo">

Now, this becomes our root folder, and accessing localhost/ will point to it.


You should also add a .htaccess file in the root folder with the following content:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [L]

This file enables URL rewriting so that when a user enters a non-existent URL, they will be redirected to index.php.

skylark's avatar

skylark wrote a comment+100 XP

2mos ago

If you don't want to use the ready-to-use method array_key_exists(), one look into the PHP docs on how to iterate associative arrays, and you can write your own function:

function uri_finder($k, $aarry) { foreach ($aarry as $key => $value) { if ($key === $k) { return $value; } } }

skylark's avatar

skylark wrote a comment+100 XP

2mos ago

@jeffreyway Thank you for fighting in the arena. Your job is not over. It has been more difficult than ever to learn well in the era of AI with all this noise, hype, race, and fog. Likewise, it has been a huge challenge to teach in this new era. That is why we need innovative and dedicated teachers, leaders, and practitioners, builders, the whole ecosystem. We need good, strong people who will cut AI to its size and put it in its place.

skylark's avatar

skylark wrote a comment+100 XP

2mos ago

Thanks, great take. What's the economics of your vibe coding?

skylark's avatar

skylark wrote a comment+100 XP

2mos ago

@JeffreyWay Fine, not human, noted. But the Notes looked and felt better in a quick scan.

skylark's avatar

skylark wrote a comment+100 XP

2mos ago

I prefer that the lesson Notes return to the PHP for Beginners series. The notes are great for quick reference. I do not need to chat with a bot anytime I need a quick refresher. The notes are from the teachers, so I trust them, and they feel human.