sqlc-php is a code generator for PHP developers who want type-safe database access without using an ORM. You write your database structure and SQL queries with simple annotations, and the tool generates PHP classes with properly typed properties and methods that execute your queries safely. It handles complex cases like JOINs, aggregate functions, and optional search filters automatically, producing clean code that's easy to understand and maintain.
How It Works
You're writing PHP code that talks to a database, and keeping track of types and parameters is becoming a nightmare.
You discover sqlc-php: a tool that reads your SQL queries and automatically creates perfectly typed PHP classes.
You install the tool and create a simple configuration file that points to your database structure and queries.
You write out your table definitions in plain SQL, like CREATE TABLE users (id INT, email VARCHAR...).
You add simple comments above your SQL queries to name them and say what they return, like 'give me all users' or 'find one user by email'.
You run the generator and watch it create PHP classes that match your database structure exactly.
You now have clean, type-safe PHP objects and methods that run your queries with proper error handling, ready to use in your application.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.