This guide explains how to set up the whole webstore from zero.
The project is a PHP CodeIgniter 4 webstore with a Svelte/Vite frontend. It uses MySQL for the database and Google OAuth for Google login.
Install these before starting:
If you use XAMPP, PHP and MySQL usually come with it. Composer and Node.js still need to be installed separately.
For XAMPP, put the project here:
C:\xampp\htdocs\FitnessCrap
Open PowerShell in that folder:
cd C:\xampp\htdocs\FitnessCrap
All commands below assume you are inside this folder unless the guide says otherwise.
Run:
composer install
This installs the backend packages into vendor/.
Important backend packages:
codeigniter4/framework: the PHP frameworkgoogle/apiclient: Google login supportInstall the root frontend icon package:
npm install
Then install the Svelte frontend packages:
cd frontend
npm install
cd ..
Important frontend packages:
svelte: reactive frontend componentsvite: frontend builder/dev serverjquery: AJAX and DOM helper libraryselect2: nicer select inputsselect2-bootstrap-5-theme: Select2 Bootstrap stylingbootstrap-icons: icon font package.envThe .env file stores local settings and secrets.
Create this file in the project root:
C:\xampp\htdocs\FitnessCrap\.env
Add this starter content:
CI_ENVIRONMENT = development
app.baseURL = 'http://localhost:1010/'
database.default.hostname = localhost
database.default.database = fitnesscrap
database.default.username = root
database.default.password =
database.default.DBDriver = MySQLi
database.default.port = 3306
GOOGLE_CLIENT_ID = ''
GOOGLE_CLIENT_SECRET = ''
Do not commit .env to Git. It contains secrets.
Run:
php spark key:generate
This adds an encryption.key value to .env.
This key is required by CodeIgniter for secure encrypted data.
Open phpMyAdmin or MySQL and create a database named:
fitnesscrap
SQL version:
CREATE DATABASE fitnesscrap CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Make sure the database name matches .env:
database.default.database = fitnesscrap
Run:
php spark migrate
This creates the database tables.
Check that migrations ran:
php spark migrate:status
Expected tables:
productstagsusersproduct_imagesproduct_tagsusers_productsuser_wishlistIf migrations fail, check that MySQL is running and that the .env database username, password, and database name are correct.
Google login needs two values:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETCreate them like this:
APIs & Services.OAuth consent screen.Credentials.Create Credentials.OAuth client ID.Web application.http://localhost:1010/auth/google/callback
.env:GOOGLE_CLIENT_ID = 'paste-client-id-here'
GOOGLE_CLIENT_SECRET = 'paste-client-secret-here'
The redirect URI must exactly match your site URL.
If you change the port from 1010, change it in both places:
.env app.baseURLRun:
cd frontend
npm run build
cd ..
This creates the built frontend files:
frontend/public/assets/index.css
frontend/public/assets/index.js
The PHP views load those built files when the app is not in development mode.
Best practice is to serve CodeIgniter from the public/ folder.
Do not point Apache directly at the project root.
Example Apache virtual host:
<VirtualHost *:1010>
DocumentRoot "C:/xampp/htdocs/FitnessCrap/public"
ServerName localhost
<Directory "C:/xampp/htdocs/FitnessCrap/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also make sure Apache has mod_rewrite enabled.
Restart Apache.
Then open:
http://localhost:1010/
Quick local alternative:
php spark serve --port 1010
Only use this while editing Svelte files.
Terminal 1:
php spark serve --port 1010
Terminal 2:
cd frontend
npm run dev
In development mode, CodeIgniter loads Svelte from:
http://localhost:3000
If port 3000 is busy, stop the other process or change frontend/vite.config.js.
First, register normally through the website.
Then open MySQL/phpMyAdmin and run:
UPDATE users
SET role = 'administrator'
WHERE email = '[email protected]';
Log out and log back in.
Admin users go to:
/adminPanel
Uploaded product images are stored in:
public/images/productsImages/
The folder must exist.
The web server must be allowed to write to it.
The fallback product image is:
public/images/defaultImage.png
Install PHP packages:
composer install
Install frontend packages:
cd frontend
npm install
Build frontend:
cd frontend
npm run build
Run migrations:
php spark migrate
Check migrations:
php spark migrate:status
List routes:
php spark routes
Check Composer security issues:
composer audit
The app loads these from CDNs:
The app loads Bootstrap Icons locally from:
public/bootstrapAssets/
Problem: Unknown column 'email_verified' or Unknown column 'is_active'
Your database is missing columns expected by the code. Run migrations first:
php spark migrate
If migrations are already marked as run, add the columns manually:
ALTER TABLE users ADD COLUMN email_verified TINYINT(1) NULL DEFAULT 0;
ALTER TABLE users ADD COLUMN is_active TINYINT(1) NULL DEFAULT 1;
Problem: Google login fails
Check:
.env has GOOGLE_CLIENT_ID..env has GOOGLE_CLIENT_SECRET.http://localhost:1010/auth/google/callback..env app.baseURL is http://localhost:1010/.Problem: CSS or Svelte behavior looks old
Rebuild the frontend:
cd frontend
npm run build
Problem: Normal routes show 404
Check:
public/.mod_rewrite enabled.AllowOverride All.Problem: Uploads fail
Check:
public/images/productsImages/ exists..env.public/.vendor/, node_modules/, and writable/ out of Git.CI_ENVIRONMENT = production on a real server.frontend/..env created.public/.If every item is done, the webstore should be ready to run.