Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
523bc73
Created navbar as a component
Jul 11, 2025
7f612de
Auto registering of helpers for twig template
Jul 11, 2025
87aee8b
Debugbar updating on every ajaxRequest
Jul 11, 2025
61f01a4
Component folder lowercased in comand
Jul 11, 2025
26f0328
Fixed the view name issue
Jul 11, 2025
1f53e22
Fixed the view name issue for htmx
Jul 11, 2025
def571e
Merge pull request #3 from SproutPHP/dev_yanik
yanikkumar Jul 11, 2025
04c5c60
Created the build command
Jul 11, 2025
99659e6
Middleware Created
Jul 11, 2025
778274e
Removed the multicomment
Jul 11, 2025
50c5212
CSRF Middleware added
Jul 11, 2025
b6e7777
MakeMiddleware sprout command done
Jul 11, 2025
e30d84b
XssProtection Middleware Added
Jul 11, 2025
df99800
Route based middleware added
Jul 11, 2025
bdcb4d8
working on Middleware alias
Jul 11, 2025
fc75b96
Fixed the CSP issue for local
Jul 11, 2025
3aaf069
added favicon
Jul 11, 2025
8c98d6b
Merge pull request #4 from SproutPHP/dev_yanik
yanikkumar Jul 11, 2025
27b0a49
Add configuration system with config() helper
Jul 14, 2025
2135c8a
Configuration feature with all fixes
Jul 14, 2025
d1feb62
Merge pull request #5 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
576ec4a
Modified the View cache and updated readme
Jul 14, 2025
088119e
Merge pull request #6 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
5e9e4ea
Updated readme
Jul 14, 2025
71220eb
Merge pull request #7 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
394e33f
Updated readme
Jul 14, 2025
5f944a7
Merge pull request #8 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
dc85592
Updated readme with bmc
Jul 14, 2025
6830566
Merge pull request #9 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
f4f5b31
Fixed the route based middleware
Jul 14, 2025
df6b305
fix: Move header() calls before output in XssProtection middleware (f…
Jul 14, 2025
24cb1fc
fixed the helper methods and updated the home page
Jul 14, 2025
f6872ef
Updated the home page with debugbar and githubtoken
Jul 14, 2025
e2b032d
Added new feature for partial_or_full render updated docs
Jul 14, 2025
93ef4a4
Updated the navbar and docs
Jul 14, 2025
2226adf
PostInstall update for pico css setup
Jul 14, 2025
d6b5def
Pico CSS setup sprout command
Jul 14, 2025
f5fae33
Merge pull request #10 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
46b0edb
Some UI and animations updates
Jul 14, 2025
6641b90
Updated Readme
Jul 14, 2025
67121e1
Merge pull request #11 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
bf86953
spelling mistakes updated
Jul 14, 2025
e403e8e
CORS middleware registerd and setup
Jul 14, 2025
6b1f464
Some minor fixes: env helper and twig_cache
Jul 14, 2025
f8f129a
Merge pull request #12 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
6091a53
Added render_fragment_or_full in twig_helpers
Jul 14, 2025
a9a1e8b
Boolean change after env helper modified
Jul 14, 2025
d478f01
Merge pull request #13 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
8db1c32
Working with validators
Jul 14, 2025
22f25a2
Removed repeated session start and started after autoload
Jul 14, 2025
f4728cd
Fixed the import
Jul 14, 2025
3777cc4
Validation Test Working
Jul 14, 2025
ef9328d
Updated with new release
Jul 14, 2025
9e4e9fa
Merge pull request #14 from SproutPHP/dev_yanik
yanikkumar Jul 14, 2025
04eda2f
New validation rules added
Jul 15, 2025
d0a0f2d
updated docs
Jul 15, 2025
f07da64
Merge pull request #15 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
0d6ad2c
Fixed the bug for header and footer in submit again request
Jul 15, 2025
226a348
Spinner added before the htmx request submission
Jul 15, 2025
2f66221
Error removing on focusin
Jul 15, 2025
0dc5ce5
Dark-Light mode switch added
Jul 15, 2025
3ee1c99
Updated postInstall script with darkmode button
Jul 15, 2025
d0230ad
Merge pull request #16 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
0ef3e93
Updated the docs for new updateds
Jul 15, 2025
414124b
Updated release notes
Jul 15, 2025
b3c1851
Merge pull request #17 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
9977e9e
Versioning and changelog created
Jul 15, 2025
eced465
Merge pull request #18 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
3636cd5
Added storage feature for file upload
Jul 15, 2025
0cb4533
Merge pull request #19 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
e701488
Added file and hasFile method in request
Jul 15, 2025
0733e2f
Merge pull request #20 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
15c106c
capture new request to get data and input method for get data
Jul 15, 2025
37e0778
New mimes and image validation
Jul 15, 2025
c9761b1
Updated the storage method to public folder
Jul 15, 2025
f05546e
Updated the example with file upload feature
Jul 15, 2025
4fb0b7c
Updated docs and release notes and changelog
Jul 15, 2025
6dee2af
Merge pull request #21 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
825da34
Added storage config
Jul 15, 2025
aec5346
Working on storage and symlink
Jul 15, 2025
811b363
Symlink command Fix
Jul 15, 2025
e521817
Udpated the name STORAGE_PUBLIC_ROOT
Jul 15, 2025
17f7fce
Merge pull request #22 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
37ba006
Updated docs
Jul 15, 2025
4251541
Merge pull request #23 from SproutPHP/dev_yanik
yanikkumar Jul 15, 2025
46bff7f
Storage relative path fixed for public stoarge
Jul 16, 2025
a4bf363
Private file storage fix
Jul 16, 2025
778f442
Added dynamic route parameters {id} {slug} working
Jul 16, 2025
a2213b3
Fixed the file download issue
Jul 16, 2025
4adebd1
new csrf_token helper added string only
Jul 16, 2025
f90ff05
updated the csrf token key
Jul 16, 2025
ef3d95c
Some UI update for SPA like feel
Jul 16, 2025
fb6e224
Added sleep to show the spinner with delayed request
Jul 16, 2025
b9bfdf2
removed delay in request
Jul 16, 2025
36132e5
updated docs and release notes and changelog
Jul 16, 2025
3376a2f
Merge pull request #24 from SproutPHP/dev_yanik
yanikkumar Jul 16, 2025
e71f298
Updated navbar links for docs and about
Jul 16, 2025
b142241
Merge pull request #25 from SproutPHP/dev_yanik
yanikkumar Jul 16, 2025
6d0e6db
Updated .gitignore with docs
Jul 16, 2025
5fd1356
Updated postinstall to download offline docs
Jul 16, 2025
6d851c4
Merge pull request #28 from SproutPHP/dev_yanik
yanikkumar Jul 16, 2025
f1e7d87
Updated the getLatestVersion to latest by default
Jul 17, 2025
21ddb34
Updated the getLatestVersion to latest by default
Jul 17, 2025
2d5eb2f
Merge pull request #29 from SproutPHP/dev_yanik
yanikkumar Jul 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,56 @@
# App
APP_NAME=SproutPHP
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:9090
APP_TIMEZONE=UTC
APP_LOCALE=en
APP_KEY=your-secret-key-here

# Repo Info For Versioning
SPROUT_REPO=SproutPHP/framework
SPROUT_USER_AGENT=sproutphp-app

# Database
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_NAME=sprout
DB_USER=root
DB_PASS=

# Mail
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@sproutphp.com
MAIL_FROM_NAME=SproutPHP

# Cache
CACHE_DRIVER=file
CACHE_PATH=/storage/cache

# Session Configuration
SESSION_NAME=sprout_session
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_PATH=/storage/sessions

# Storage
STORAGE_DISK=public
STORAGE_PUBLIC_ROOT=storage/app/public
STORAGE_PUBLIC_URL=/storage
STORAGE_PRIVATE_ROOT=storage/app/private

# Security
CSRF_ENABLED=true
XSS_PROTECTION=true
CORS_ENABLED=false

# View
VIEW_ENGINE=twig
TWIG_CACHE=false
TWIG_DEBUG=true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ composer.lock

# Application specific
/public/uploads/
/public/storage/
/public/storage/
/docs
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Changelog

All notable changes to this project are documented in this file.

This project uses [Semantic Versioning](https://semver.org/) beginning with version `v0.1.7-alpha.2` (or `v0.1.7-beta.1`).
Earlier releases (`v0.1.0-alpha.1` to `v0.1.7-alpha.1`) were experimental and do not strictly follow SemVer conventions.

---

## [v0.1.7-alpha.3] - 2024-06-13

### Added
- Storage root is now set to an absolute path by default for reliability (no .env needed)
- Improved Storage helper documentation and usage
- Enhanced symlink command for better cross-platform compatibility
- Updated documentation for new storage system and best practices

### Fixed
- Prevented duplicate/nested storage paths in uploads
- General codebase and documentation improvements

---

## [v0.1.7-alpha.2] - 2025-07-15

### Added
- Storage helper for file uploads, saving to `public/uploads` and generating URLs.
- Modern file access in controllers: `$request->file('avatar')`, `$request->hasFile('avatar')`.
- Unified request data: merges `$_GET`, `$_POST`, and JSON body.
- `mimes` and `image` validation rules for secure file uploads.
- HTMX-powered file upload with progress bar in the main form (no JS required).
- Generic error-clearing script for all form fields.

### Changed
- File uploads are now web-accessible by default.
- Improved documentation for file upload, validation, and request handling.

### Fixed
- No more duplicate `/uploads/uploads/...` in file URLs.

---

## Legacy Experimental Releases

These were single-shot development releases with no progressive alpha/beta cycle.

| Version Tag | Notes |
| ---------------- | ----------------------------------------- |
| `v0.1.0-alpha.1` | Initial experimental release |
| `v0.1.1-alpha.1` | Feature/bug updates without SemVer phases |
| `v0.1.2-alpha.1` | Same as above |
| `v0.1.3-alpha.1` | — |
| `v0.1.4-alpha.1` | — |
| `v0.1.5-alpha.1` | — |
| `v0.1.6-alpha.1` | — |
| `v0.1.7-alpha.1` | Final experimental/unstable release |

---

**From v0.1.7-alpha.2 onward, all releases will follow a structured, progressive SemVer pre-release cycle.**

## [v0.1.7-beta.1] - 2024-06-09

### Added
- Dynamic route parameter support (e.g., `/user/{id}`, `/blog/{slug}`) for CRUD and flexible routing
- Robust CSRF protection via middleware and helpers (works for forms, AJAX, and HTMX)
- SPA-like file upload and form handling with HTMX (including indicators and grid UI)
- Secure private file upload/download (no direct links, internal access only)
- Consistent CSRF token management (single session key, helpers, and middleware)

### Improved
- UI/UX for validation and file upload forms (two-column grid, spinner, SPA feel)
- Path resolution for storage (public/private separation, symlink support)
- Code structure: CSRF logic moved to helpers/middleware, no raw PHP in entry

### Fixed
- Issues with file download on PHP built-in server (now uses query param for compatibility)
- Consistency in CSRF token usage across the framework

### Removed
- Exposed raw CSRF logic from entry point

---
156 changes: 156 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# SproutPHP Configuration Guide

This document outlines all available configuration options for SproutPHP framework.

## Environment Variables (.env file)

### Application Configuration
```env
APP_NAME=SproutPHP
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:9090
APP_TIMEZONE=UTC
APP_LOCALE=en
APP_KEY=your-secret-key-here
```

### Database Configuration
```env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_NAME=sprout
DB_USER=root
DB_PASS=
DB_PREFIX=
```

### Security Configuration
```env
# CSRF Protection
CSRF_ENABLED=true
CSRF_TOKEN_NAME=_token
CSRF_EXPIRE=3600

# XSS Protection
XSS_PROTECTION=true
XSS_MODE=block # 'block', 'sanitize', or '0' to disable

# Content Security Policy
CSP_ENABLED=true
CSP_REPORT_ONLY=false
CSP_REPORT_URI=

# CORS
CORS_ENABLED=false
CORS_ALLOWED_ORIGINS=*
CORS_ALLOWED_METHODS=GET,POST,PUT,DELETE
CORS_ALLOWED_HEADERS=Content-Type,Authorization
```

### Mail Configuration
```env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@sproutphp.com
MAIL_FROM_NAME=SproutPHP
```

### Cache Configuration
```env
CACHE_DRIVER=file
CACHE_PATH=/storage/cache
```

### Session Configuration
```env
SESSION_NAME=sprout_session
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_PATH=/storage/sessions
```

### Logging Configuration
```env
LOG_DRIVER=file
LOG_LEVEL=debug
LOG_PATH=/storage/logs
```

### View Configuration
```env
VIEW_ENGINE=twig
TWIG_CACHE=false
TWIG_DEBUG=true
TWIG_AUTO_RELOAD=true
TWIG_STRICT_VARIABLES=false
```

### Framework Configuration
```env
SPROUT_REPO=SproutPHP/framework
SPROUT_USER_AGENT=sproutphp-app
```

## Configuration Usage

### In PHP Code
```php
// Get app name
$appName = config('app.name');

// Get database host
$dbHost = config('database.connections.mysql.host');

// Check if XSS protection is enabled
$xssEnabled = config('security.xss.enabled');

// Get CSP mode
$cspMode = config('security.csp.report_only');
```

### In Twig Templates
```twig
{# Get app name #}
<h1>{{ config('app.name') }}</h1>

{# Check environment #}
{% if config('app.env') == 'local' %}
<div class="debug-info">Development Mode</div>
{% endif %}
```

## Security Features

### XSS Protection
The framework automatically adds XSS protection headers based on your configuration:

- **Development**: Relaxed CSP policy allowing inline styles and external images
- **Production**: Strict CSP policy for maximum security

### CSRF Protection
CSRF tokens are automatically generated and validated for state-changing requests (POST, PUT, PATCH, DELETE).

### Content Security Policy
CSP headers are automatically set based on your environment:
- **Local/Debug**: Allows `unsafe-inline` for styles and external images
- **Production**: Strict policy with no unsafe directives

## Environment-Specific Behavior

### Local Environment
- Debug information displayed
- Relaxed security policies
- Detailed error messages
- HTMX debug indicator

### Production Environment
- No debug information
- Strict security policies
- Generic error pages
- Optimized performance settings
Loading