Overview
NewsPortal Pro is a full-featured, production-ready news magazine application built on Laravel 12, PHP 8.2, and Bootstrap 5.3. It provides everything a professional publication needs out of the box โ editorial workflows, AI enrichment, comment moderation, newsletter management, and a beautiful responsive frontend.
NewsPortal Pro ships with one-command setup scripts โ setup.bat for Windows and setup.sh for Linux/Mac. These handle everything automatically. See the Setup Guide for step-by-step instructions.
Requirements
| Requirement | Version | Notes | Status |
|---|---|---|---|
| PHP | 8.2+ | Required extensions: pdo_mysql, mbstring, xml, gd, zip, bcmath, curl | Required |
| Composer | 2.x | PHP dependency manager | Required |
| MySQL | 8.0+ | MariaDB 10.4+ also supported | Required |
| Laravel | 12.x | Installed via Composer | Required |
| OpenAI API Key | Any | Only needed for AI features | Optional |
| SMTP Server | Any | Gmail, Mailtrap, Mailgun etc. | Optional |
Recommended Windows Environments
- Laragon โ Best option. Includes PHP 8.2, MySQL 8, Composer in one installer. laragon.org
- XAMPP โ Use the PHP 8.2 version. apachefriends.org
- Laravel Herd โ Laravel's official local environment. herd.laravel.com
Installation
Option A โ One-Command Setup (Recommended)
# Windows โ double-click or run in Command Prompt
> setup.bat
# Linux / macOS
$ chmod +x setup.sh && ./setup.sh
The script will prompt you for database credentials, create the database automatically, install all dependencies, run migrations, and seed demo data.
Option B โ Manual Steps
# 1. Install dependencies
$ composer install
# 2. Copy environment file
$ cp .env.example .env
# 3. Generate application key
$ php artisan key:generate
# 4. Edit .env with your DB credentials (see below)
# 5. Create database in MySQL
mysql> CREATE DATABASE news_portal CHARACTER SET utf8mb4;
# 6. Run migrations + seed demo data
$ php artisan migrate --seed
# 7. Start the development server
$ php artisan serve
INFO Server running on http://127.0.0.1:8000
After setup: Frontend โ http://localhost:8000 ยท Admin โ http://localhost:8000/admin ยท Login: admin@example.com / password
File Structure
Environment (.env)
Copy .env.example to .env and configure the following key values:
# Application
APP_NAME="News Portal"
APP_URL=http://localhost:8000
# Database
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=news_portal
DB_USERNAME=root
DB_PASSWORD=your_password
# AI โ also configurable from Admin โ Settings โ AI
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
# Mail โ also configurable from Admin โ Settings โ Email
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_USERNAME=you@gmail.com
MAIL_PASSWORD=your_app_password
Both AI and Email settings can be managed entirely from the Admin panel without editing .env. The .env values serve only as fallbacks.
Roles & Permissions
NewsPortal Pro uses four distinct user roles, each with precisely scoped permissions.
| Permission | Admin | Editor | Author | Reader |
|---|---|---|---|---|
| Access admin panel | โ | โ | โ | โ |
| Create articles | โ | โ | โ | โ |
| Edit own articles | โ | โ | โ | โ |
| Edit all articles | โ | โ | โ | โ |
| Publish articles | โ | โ | โ | โ |
| Delete articles | โ | โ | โ | โ |
| Manage comments | โ | โ | โ | โ |
| Manage categories | โ | โ | โ | โ |
| Run AI enrichment | โ | โ | โ | โ |
| Manage users | โ | โ | โ | โ |
| Access all settings | โ | โ | โ | โ |
The Users and Settings menu items are hidden from Editors in the sidebar, and the routes are protected by the is_admin_only middleware. Direct URL access returns a 403.
AI Suite โ Overview
NewsPortal Pro integrates with OpenAI's Chat Completions API to provide four intelligent publishing features. All AI functionality is handled by App\Services\AIService.
The site works completely without AI. If no API key is set or AI is disabled, all AI features no-op gracefully with no errors.
AI Feature Toggles
| Feature | Setting Key | What it does |
|---|---|---|
| Summary | ai_feature_summary | Generates a 2โ3 sentence neutral summary shown on article cards and detail pages |
| Tags | ai_feature_tags | Suggests and auto-attaches 3โ6 relevant tags when an article is published |
| SEO | ai_feature_seo | Generates meta title (โค60 chars) and meta description (โค155 chars) |
| Related | ai_feature_related | Surfaces contextually relevant articles in the sidebar |
Configuration
Configure AI from Admin โ Settings โ AI:
- Paste your OpenAI API key (from platform.openai.com)
- Select your preferred model (
gpt-4o-miniis cheapest and recommended) - Toggle the master switch Enable AI Features ON
- Toggle individual features as needed
# Manually process AI on all unprocessed articles
$ php artisan news:process-ai
# Process with a limit
$ php artisan news:process-ai --limit=20
# Re-process a specific article by ID
$ php artisan news:reprocess-ai 5
Artisan Commands
Six custom Artisan commands are included in routes/console.php:
| Command | Description | Type |
|---|---|---|
news:stats | Display full site statistics in a table | Utility |
news:process-ai [--limit=N] | Run AI enrichment on all unprocessed articles | AI |
news:reprocess-ai {id} | Force re-run AI on a specific article by ID | AI |
news:send-newsletter "Subject" [--preview] | Email all confirmed subscribers | |
news:publish-scheduled | Publish articles whose scheduled time has passed | Scheduler |
news:clear-spam | Permanently delete all spam-flagged comments | Utility |
Troubleshooting
Syntax error in Blade views
If you see "unexpected token '='" in a Blade view, ensure you are not using inline associative arrays with => inside @foreach directives. Always move them to a @php block first:
// โ Causes XAMPP Blade parser issues
@foreach(['key'=>'value'] as $k => $v)
// โ
Correct approach
@php $arr = ['key' => 'value']; @endphp
@foreach($arr as $k => $v)
Pagination looks unstyled
Ensure AppServiceProvider::boot() contains:
Paginator::useBootstrapFive();
SQLSTATE: Access denied
Double-check DB_USERNAME and DB_PASSWORD in your .env file. For XAMPP, the default is root with no password.
Uploaded images not appearing
Ensure the public/uploads/ directory exists and is writable. On Linux/Mac, run chmod -R 775 public/uploads.
AI features not working
Check: (1) Admin โ Settings โ AI master switch is ON. (2) API key is set. (3) Your server can reach api.openai.com โ some hosts block outbound HTTPS to external APIs.
All errors are logged to storage/logs/laravel.log. Check this file first when debugging unexpected behaviour.
Changelog
- Initial release with Laravel 12 + PHP 8.2
- Full AI suite (summary, tags, SEO, related) with per-feature toggles
- 4-role RBAC system with middleware protection
- Quill rich text editor integration
- Scrollable category nav with arrow buttons
- Bootstrap 5 pagination configured globally
- 30 seeded articles, 17 users, 80 tags, 150+ comments
- One-command setup scripts for Windows and Linux/Mac
- 6 custom Artisan commands
- SMTP configuration from Admin panel at runtime