Text to Meme Generator PHP Script
AI Tools
MemeForge AI is a self-hosted, AI-powered meme generator built in PHP 8 and MySQL. It connects Google Gemini AI with the Imgflip API to automatically pick the right meme template and write the captions — all from a simple text prompt entered by the user. No design skills needed. No manual template selection. The user types what they want, selects a language, and the AI does everything else: it reads the prompt, picks the best-matching meme format from over 100 popular templates, writes the top and bottom captions, and delivers a ready-to-share meme image in seconds.
Text to Meme Generator PHP Script
MemeForge AI is a self-hosted PHP 8 meme generator script that uses Google Gemini AI to turn any text prompt into a ready-to-share meme in seconds. It automatically selects the best-matching template from 100+ popular Imgflip formats, writes the captions, and renders the final image — all without any manual template browsing or design work. Built on pure PHP 8 and MySQL with no framework dependencies, it includes a web installer, session-based meme history, a community gallery, download and social share buttons, and a full admin panel for managing memes, templates, and API settings. Both required APIs — Google Gemini and Imgflip — have free tiers, making it free to run at moderate traffic. Supports 15 languages out of the box. Full unencrypted source code included, no domain restrictions, one-time payment.
Key Features
AI-Driven Meme Generation
- Google Gemini 1.5 Flash AI analyzes the user's text and selects the best-fitting meme template from 100+ popular formats
- AI writes punchy, viral-style captions that match the chosen template's humor pattern
- Regenerate button lets users get a different template for the same prompt without retyping
Multi-Language Support
- Supports 15 languages out of the box: English, Spanish, French, German, Portuguese, Italian, Dutch, Russian, Japanese, Hindi, Arabic, Korean, Chinese (Simplified), Turkish, and Polish
- Gemini handles translation and adapts captions for cultural tone — no separate translation API required
Community Gallery
- Public gallery displays the most recent memes generated on the site
- Session-based personal history tab lets users revisit their own memes within the same session
- Each gallery card shows the original prompt, meme template name, generation time, and language badge
Download and Social Sharing
- One-click secure download via a PHP proxy handler
- Pre-built share links for X (Twitter) and WhatsApp
- Generated meme images are hosted on Imgflip's CDN — no server storage required
Imgflip Template Cache
- Top 100 Imgflip templates are fetched once and cached in MySQL for 24 hours
- Reduces API calls to Imgflip and keeps the generator fast on every request
- Admin can force-refresh the cache at any time from the dashboard
Admin Panel
- Dashboard with stats: total memes generated, today's count, top languages, most-used templates
- Template browser: view all 100 cached templates with a live search filter
- Settings page: update API keys, app name, tagline, admin password, and gallery limit — all via a simple form
- Meme management: view and delete any generated meme from a sortable table
Web Installer
- One-page installation wizard at /install/install.php
- Creates the MySQL database, installs both tables, and writes the config file automatically
- No manual SQL import or config file editing needed
How It Works
- Step 1 — User enters a text prompt The user types any idea, topic, or situation — for example, "when the Wi-Fi drops during an important meeting" — and selects a target language from the dropdown.
- Step 2 — Templates are loaded from cache The script checks MySQL for a cached copy of the top 100 Imgflip meme templates. If the cache is fresh (under 24 hours), it uses that. Otherwise it fetches a new list from the Imgflip API and stores it.
- Step 3 — Gemini AI picks the template and writes captions The prompt and template list are sent to Google Gemini 1.5 Flash. Gemini returns the best template ID, a top text caption, a bottom text caption, and a one-sentence reasoning explaining the choice.
- Step 4 — Imgflip renders the image The script calls Imgflip's /caption_image endpoint with the chosen template ID and captions. Imgflip returns a public image URL pointing to the finished meme.
- Step 5 — Meme is displayed and saved The meme appears on screen with the template name, AI reasoning note, download button, and share links. The generation is saved to the generated_memes MySQL table linked to the user's session.
Technical Specifications
- Language: PHP 8.0+
- Database: MySQL 5.7+ or MariaDB 10.3+
- Framework: None — pure PHP, no Laravel, no Symfony
- AI API: Google Gemini 1.5 Flash (free tier: 1,500 requests/day, no credit card required)
- Meme API: Imgflip (free account: generates memes with small watermark; $9.99/month Premium removes watermark)
- PHP Extensions Required: pdo_mysql, allow_url_fopen or curl
- Installation: Web-based installer wizard included
- Encryption: None — 100% readable, modifiable source code
- Domain Restrictions: None
Database Tables:
| Table | Purpose |
|---|---|
| memes_cache | Stores the Imgflip template list with a timestamp for cache management |
| generated_memes | All generated memes with prompt, template, captions, image URL, language, session ID, and timestamp |
API Keys — Both Free
- Google Gemini API Get a free API key at aistudio.google.com. The free tier supports up to 1,500 requests per day using Gemini 1.5 Flash — more than enough for a small to medium meme site. No credit card required.
- Imgflip Create a free account at imgflip.com. Your username and password go into the config. Free tier generates memes with a small Imgflip watermark in the corner. Upgrade to Imgflip Premium API ($9.99/month) to remove the watermark entirely.
Who Is This For?
- Digital Marketers and Content Teams Produce branded meme content for social media campaigns in any language without a design team or Canva subscription.
- Educators and Trainers Create engaging, relatable meme visuals to support learning content. Generate memes in the student's native language in one click.
- Entrepreneurs and SaaS Builders White-label this script and launch your own branded meme generator site. Change the app name, colors, and domain — full source code included.
- PHP Developers Use as a foundation to build a meme marketing platform, community site, or add meme generation to an existing app. Clean, readable, framework-free PHP 8.
Frequently Asked Questions
1. Does this require any paid APIs?
No. Both the Google Gemini API and Imgflip API have free tiers that are fully functional. The Imgflip free tier adds a small watermark to generated memes. You can optionally upgrade Imgflip to remove it.
2. Do I need a database?
Yes. MemeForge AI uses MySQL to cache meme templates and store generated meme history. The installer creates all tables automatically.
3. Does this work on shared hosting?
Yes. It runs on any standard PHP 8 shared hosting environment. No special server configuration is needed beyond PHP and MySQL.
4. Can I change the app name and branding?
Yes. The app name, tagline, and color scheme are fully customizable. You can change the name to anything — MemeForge AI is a generic starting point.
5. Can I use this for a multi-language audience?
Yes. Gemini handles translation natively. You can add more languages by editing a single array in the gemini.php file.
6. What happens when I regenerate a meme?
Clicking Regenerate sends the same prompt back to Gemini, which selects a different template and writes fresh captions. Each regeneration is saved as a separate record in the database.
7. Is the source code encrypted or obfuscated?
No. Every file is plain, readable PHP. You can modify, extend, or rebrand anything without restriction.
8. How many memes can it generate per day?
On Gemini's free tier, up to 1,500 meme generations per day. Imgflip's free API has no hard daily limit but may throttle heavy usage. For high-traffic sites, both APIs offer affordable paid tiers.
What's Included
- Full PHP 8 source code (14 files, zero dependencies)
- MySQL installer wizard
- Admin panel (dashboard, template browser, settings)
- README with step-by-step setup instructions
- Lifetime access — one-time payment, no subscription
- Free future updates for bug fixes
Pricing
MemeForge AI — $45
- Full source code, no encryption
- No domain restrictions
- No monthly fees
- Web installer included
- Admin panel included
- Lifetime access
License
A regular license permits the use of an item in a single project, whether for personal or commercial purposes, by you or on behalf of a client. Resale of the item, either individually or as part of a project, is prohibited, and the distribution of source files is not allowed.
Hosting Requirements
Compatible with MySQL 5.7 or higher, Apache module, PHP 8.2 or above, on Windows or Linux servers. (Note. For seamless our script performance, compatibility at a low price, we highly recommend Hostinger—reliable, fast, and built for excellence!)
Server Requirements
- Language: PHP 8.0+
- Database: MySQL 5.7+ or MariaDB 10.3+
- Framework: None — pure PHP, no Laravel, no Symfony
- AI API: Google Gemini 1.5 Flash (free tier: 1,500 requests/day, no credit card required)
- Meme API: Imgflip (free account: generates memes with small watermark; $9.99/month Premium removes watermark)
- PHP Extensions Required: pdo_mysql, allow_url_fopen or curl
- Installation: Web-based installer wizard included
- Encryption: None — 100% readable, modifiable source code
- Domain Restrictions: None
Payment Type
One time Payment: Upon receiving your full payment, we will provide you with the complete source code. After that, no additional payments will be required.
Delivery Time
We will send the Download Link to you Within 2-4 hrs. On Working Days(Monday- Friday) And the source code will deliver within 4-8 hours On Weekends (Saturday -Sunday).
Technical Support
Unlimited Email Support for One Year.
Script Update
Free Updates for One Year.
Customization Scope
Includes Complete Source Code.
Encryption
No Encryption and No Domain Limitations.
Installation
No Free Installation Services. Our charges range from $5 to $10, depending on the software's complexity and criticality.
No comments yet. Be the first to comment!