This video will be available to
subscribers on Thu, May 15, 2025.
You must be a subscriber to view this video.
May 15, 2025
21m:3s

Database Connections / Migrations

Classification
Software Engineering | Languages | PHP
Keywords
oop | php

About This Episode:

Let’s connect our app to the real world of data! In this video, we build a reliable and secure database layer and run our first migrations and seed scripts. This step sets the stage for persistent data handling in our application. 🧱

Here’s what we cover:
• Temporarily hijack index.php for local development and testing purposes 🔧
• Add database/migrate.sql and database/seed.sql to define and populate our schema 🧬
• Use file_get_contents() to load SQL scripts and run them using PDO 🎯
• Define connection settings: host, port, database name, user, and password (with Docker-friendly defaults) 🐳
• Set up secure PDO options for error handling and safe queries 🔐
• Wrap everything in a try/catch to safely execute migrations and seeding 🚨
• Introduce our app’s database structure:
• users – for login info 👤
• photos – uploaded images 📸
• reviews – ratings and comments ⭐📝
• Protect sensitive credentials by moving them into a .env file 🛡️
• Create a Framework/Env.php class to access environment variables cleanly 🌱

By the end of this video, version v11-db-basics will bring real data into play—securely, cleanly, and pragmatically. 🚀
Bob Cravens

Bob Cravens

Your Instructor
more »
Owner
TekFoundry
Wisconsin
United States
Short Bio:
Bob Cravens is a seasoned technology leader, software architect, and educator with a passion for empowering others through practical, real-world knowledge. As the founder of TekFoundry, Bob has dedicated his career to designing and delivering innovative software solutions that combine cutting-edge technology with elegant simplicity.

At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.

Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.

When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.