This project is a Single Page Application (SPA) built with CodeIgniter 4, Alpine.js, and AdminLTE. It provides a seamless user experience with dynamic content loading and a responsive admin interface.
- Single Page Application (SPA) architecture
- CodeIgniter 4 backend
- Alpine.js for reactive UI components
- AdminLTE for admin dashboard layout and components
- Dynamic content loading without full page reloads
- Responsive design
- PHP 7.4 or higher
- Composer
- Node.js and npm
-
Clone the repository: git clone https://github.com/jkpaguio/ci4_starter_spa.git cd ci4_starter_spa
-
Install PHP dependencies: composer install
-
Install JavaScript dependencies: npm install
-
Copy
env
to.env
and tailor for your app, specifically the baseURL and any database settings: cp env .env -
Set up your database and update the
.env
file with your database credentials. -
Run database migrations: php spark migrate Copy
-
Start the development server: php spark serve
Alternatively, if you're using a different web server (like Apache or Nginx), ensure your server is configured to point to the public
directory of your project.
If you're using Apache, ensure you have mod_rewrite enabled and use the following .htaccess
file in your public
directory:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
app/Controllers/
: Contains all the controllersapp/Views/
: Contains view filespublic/
: Publicly accessible filesjs/
: JavaScript files including Alpine.js and custom scriptscss/
: CSS filesassets/
: AdminLTE assets
app/Views/layout/main.php
: Main layout filepublic/js/router.js
: Handles SPA routingapp/Controllers/BaseController.php
: Base controller with common functionalityapp/Controllers/Home.php
: Main controller for handling routes
- Create a new view file in
app/Views/
- Add a new method in
app/Controllers/Home.php
- Update
public/js/router.js
to handle the new route - Add a new menu item in
app/Views/layout/navigation.php
- Custom CSS can be added to
public/css/custom.css
- AdminLTE styles can be overridden in the same file
- Add custom JavaScript to
public/js/custom.js
- For page-specific scripts, create new JS files and load them conditionally
- If you encounter 404 errors, ensure your
.htaccess
file is correctly set up and AllowOverride is set to All in your Apache configuration. - For database connection issues, double-check your
.env
file settings. - If AdminLTE components are not working, make sure all required CSS and JS files are properly included.
- CodeIgniter Team
- Alpine.js
- AdminLTE
- All other open-source libraries used in this project