A secure digital signature service built with PHP that allows users to create contracts and collect electronic signatures through both a web interface and RESTful API.
- Create digital contracts
- Send signing invitations via email
- Secure signature collection with tokens
- Session management and CSRF protection
- Rate limiting for security
- Modern responsive web interface
- RESTful API for integration
- Docker support for easy deployment
- Docker and Docker Compose
- OR PHP 8.0+ with Composer
- Clone the repository:
git clone <repository-url>
cd e-signature-service- Configure environment variables:
cp .env.example .env
# Edit .env with your SMTP settings- Start with Docker Compose:
docker-compose up -d- Open your browser and navigate to
http://localhost:8000
To inspect outgoing emails during development, use the provided docker-compose.override.yml
which starts a MailHog container. Emails sent by the application will be
available at http://localhost:8025.
- Navigate to the home page
- Click "Create New Contract"
- Fill in the contract details and add signers
- Submit the form to create the contract
- Signers receive an email with a signing link
- Click the link to access the signing page
- Review the contract and sign
- Submit to complete the signing process
The service provides a RESTful API for programmatic access. See API_DOCUMENTATION.md for detailed documentation.
# Create a contract
curl -X POST http://localhost:8000/api/contracts \
-H "X-API-Key: demo-api-key-123" \
-H "Content-Type: application/json" \
-d '{
"title": "Service Agreement",
"contract_text": "Contract content here...",
"signers": [{"email": "signer@example.com"}]
}'
# List contracts
curl -X GET http://localhost:8000/api/contracts \
-H "X-API-Key: demo-api-key-123"- CSRF token protection
- Rate limiting (30 requests per minute for API, 10 for web)
- Session timeout management
- Secure token-based signing
- Input sanitization and validation
- API key authentication
├── docker-compose.yml # Docker configuration
├── Dockerfile # Docker image definition
├── .env # Environment variables
├── composer.json # PHP dependencies
├── API_DOCUMENTATION.md # API documentation
src/
├── index.php # Main application entry point
├── functions.php # Core business logic
├── MailClient.php # Email sending
├── RateLimiter.php # Rate limiting functionality
├── SessionManager.php # Session management
├── api/
│ └── index.php # API endpoints
└── public/ # Frontend files
├── index.html # Home page
├── create.html # Contract creation
└── sign.html # Contract signing
data/
└── contracts/ # Contract storage (JSON files)
Configure the following variables in your .env file (example uses MailHog for local testing):
# SMTP Configuration
SMTP_HOST=mailhog
SMTP_PORT=1025
SMTP_USER=
SMTP_PASS=
# Application Configuration
APP_URL=http://localhost:8000
APP_ENV=developmentSMTP must be configured for email delivery. When running docker-compose with the
provided docker-compose.override.yml, MailHog will be available at http://localhost:8025
and the default settings in .env.example will work out of the box.
GET /api/status- API status and informationGET /api/contracts- List all contractsGET /api/contracts/{id}- Get contract detailsPOST /api/contracts- Create new contractPUT /api/contracts/{id}- Update contractDELETE /api/contracts/{id}- Delete contractGET /api/signatures/{contract_id}- Get signature statusPOST /api/signatures- Sign contract
For detailed API documentation, see API_DOCUMENTATION.md.
- CSRF Token Error: Ensure cookies are enabled and the session is properly maintained
- Email Not Sending: Check SMTP configuration in
.envfile - Permission Denied: Ensure
data/contractsdirectory has write permissions - API Authentication: Verify the
X-API-Keyheader is included in requests
# View logs
docker-compose logs esig-api
# Restart services
docker-compose restart
# Rebuild containers
docker-compose up --buildThis project is licensed under the MIT License.