cimembership / cimembership
CodeIgniter 4 Membership Management System - Base Platform
Requires
- php: ^8.1
- codeigniter4/framework: ^4.5
- codeigniter4/settings: ^2.0
- gregwar/captcha: ^1.2
- league/oauth2-client: ^2.7
- league/oauth2-facebook: ^2.2
- league/oauth2-github: ^3.1
- league/oauth2-google: ^4.0
- league/oauth2-instagram: ^3.1
- league/oauth2-linkedin: ^5.1
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- codeigniter4/devkit: ^1.3.0
- fakerphp/faker: ^1.9
- phpunit/phpunit: ^10.5
README
A modern, secure membership management system built with CodeIgniter 4.
Features
- Modern CodeIgniter 4 - Built on the latest CodeIgniter 4.x framework
- PHP 8.1+ - Uses modern PHP features for better performance and security
- Secure Authentication - Password hashing with bcrypt, CSRF protection, rate limiting
- OAuth Social Login - Facebook, Google, GitHub, LinkedIn, Twitter, Microsoft
- Role-Based Access Control - Flexible user groups and permissions
- User Profiles - Complete user profile management with avatar upload
- Admin Dashboard - Beautiful dashboard with user management
- Email Activation - Optional email verification for new accounts
- Password Reset - Secure password reset via email
- API Ready - RESTful API with API key authentication
- CLI Installer - Modern command-line installation
- Upgrade Path - Migrate from CI3 CIMembership seamlessly
Requirements
- PHP 8.1 or higher
- MySQL 5.7+ or MariaDB 10.3+
- Composer
- Web server (Apache/Nginx)
Installation
Quick Start
# Install via Composer composer create-project cimembership/cimembership cimembership cd cimembership # Run the installer php spark install:app
Manual Installation
- Download the latest release
- Extract to your web server directory
- Run
composer install - Copy
.env.exampleto.envand configure - Run
php spark migrate - Create an admin user
For detailed instructions, see INSTALL.md.
Upgrading from v3 (CI3)
If you're upgrading from CIMembership v3 (CodeIgniter 3):
# After installing v4, run the upgrade command
php spark upgrade:fromv3
This will migrate your users, groups, profiles, and settings from CI3 to CI4.
See UPGRADE.md for detailed upgrade instructions.
Directory Structure
cimembership/
├── app/
│ ├── Commands/ # CLI commands (installer, upgrade)
│ ├── Config/ # Configuration files
│ ├── Controllers/ # Base controllers
│ ├── Database/
│ │ └── Migrations/ # Database migrations
│ ├── Filters/ # Authentication & security filters
│ ├── Libraries/ # Core libraries
│ │ ├── Auth/ # Authentication classes
│ │ ├── Captcha/ # Captcha handling
│ │ └── OAuth/ # OAuth providers
│ ├── Models/ # Database models
│ └── Modules/
│ ├── Admin/ # Admin module (Dashboard, Users, Settings)
│ └── Auth/ # Auth module (Login, Register, OAuth)
├── public/ # Web root
├── tests/ # Unit tests
├── writable/ # Cache, logs, uploads
├── composer.json
└── spark # CLI entry point
Configuration
Environment Variables
Copy .env.example to .env and configure:
cp .env.example .env
Required Settings
# Environment (production for live sites) CI_ENVIRONMENT = production # Database (required) database.default.hostname = localhost database.default.database = your_database_name database.default.username = your_database_user database.default.password = your_secure_password database.default.DBPrefix = ci_ # Application URL (required) app.baseURL = 'https://yourdomain.com/' app.timezone = 'UTC'
Optional Settings
# Email (for user activation, password reset) email.protocol = smtp email.SMTPHost = smtp.yourdomain.com email.SMTPUser = noreply@yourdomain.com email.SMTPPass = your_email_password email.SMTPPort = 587 email.SMTPCrypto = tls # OAuth - Facebook cimembership.oauth.facebook.enabled = true cimembership.oauth.facebook.clientId = your_facebook_app_id cimembership.oauth.facebook.clientSecret = your_facebook_app_secret # OAuth - Google cimembership.oauth.google.enabled = true cimembership.oauth.google.clientId = your_google_client_id cimembership.oauth.google.clientSecret = your_google_client_secret # reCAPTCHA (for spam protection) cimembership.recaptcha.enabled = true cimembership.recaptcha.siteKey = your_recaptcha_site_key cimembership.recaptcha.secretKey = your_recaptcha_secret_key
OAuth Configuration
Enable OAuth providers in Admin > Settings > OAuth:
- Go to Admin Dashboard
- Navigate to Settings > OAuth
- Enter your Client ID and Client Secret for each provider
- Enable the providers you want to use
Note: Configure redirect URLs in your OAuth app:
- Facebook:
https://example.com/auth/oauth/facebook/callback - Google:
https://example.com/auth/oauth/google/callback - GitHub:
https://example.com/auth/oauth/github/callback - LinkedIn:
https://example.com/auth/oauth/linkedin/callback
CLI Commands
# Installation php spark install:app # Upgrade from v3 php spark upgrade:fromv3 --source-db=old_cimembership_db --source-prefix=ci_ # Database php spark migrate php spark migrate:rollback php spark migrate:refresh # Seeds php spark db:seed UserSeeder
Security Features
- Password Hashing: bcrypt with cost factor 12
- CSRF Protection: All forms protected by default
- Rate Limiting: Login attempts limited per IP
- Session Security: Regenerated on login
- XSS Protection: Output escaping by default
- SQL Injection Prevention: Parameterized queries
- Password Strength: Configurable minimum requirements
API Usage
CIMembership v4 includes a RESTful API:
# Get API key from Admin panel curl -H "X-API-Key: your-api-key" \ https://example.com/api/users # Create user curl -X POST \ -H "X-API-Key: your-api-key" \ -H "Content-Type: application/json" \ -d '{"username":"john","email":"john@example.com","password":"secret"}' \ https://example.com/api/users
Troubleshooting
Common Issues
Installation fails with database error:
- Check MySQL credentials in
.env - Ensure database exists and user has privileges
- Check MySQL version (5.7+ required)
OAuth not working:
- Verify redirect URLs are configured correctly
- Check Client ID and Secret are correct
- Ensure callback URLs are HTTPS in production
Emails not sending:
- Configure SMTP settings in
.env - Check server allows outgoing SMTP connections
- Review logs in
writable/logs/
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure:
- Code follows PSR-12 coding standards
- All tests pass
- Documentation is updated
License
CIMembership is open-source software licensed under the MIT license.
Support
- Documentation: https://github.com/cimembership/cimembership/blob/main/README.md
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Note: This is a complete rewrite from the original CIMembership v3. While we've provided an upgrade path, please backup your data before migrating.