Skip to content

Commit 711dfd6

Browse files
committed
Migrace na Debian PHP autoloader systém
- Aktualizován debian/README.Debian s instrukcemi pro Debian autoloader - Přechod z vendor/autoload.php na /usr/share/php/*/autoload.php - Využití pkg-php-tools a phpab pro generování autoloaderu - Dokumentace pro migraci existujících aplikací
1 parent 9c34ccd commit 711dfd6

3 files changed

Lines changed: 253 additions & 33 deletions

File tree

Examples/panel.php

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Example usage of Ease\TWB4\Panel class
7+
* This demonstrates how to properly use the Panel class from php-ease-twbootstrap4
8+
* and helps fix "Class CardHeader not found" errors in other projects.
9+
*/
10+
11+
require_once __DIR__ . '/vendor/autoload.php';
12+
13+
use Ease\TWB4\Panel;
14+
use Ease\Html\H3Tag;
15+
use Ease\Html\PTag;
16+
use Ease\Html\ATag;
17+
use Ease\Html\ButtonTag;
18+
19+
echo "<!DOCTYPE html>\n<html>\n<head>\n";
20+
echo "<title>Panel Usage Examples</title>\n";
21+
echo "<link href='https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css' rel='stylesheet'>\n";
22+
echo "</head>\n<body class='container mt-4'>\n";
23+
24+
// Example 1: Basic Panel with header, body and footer
25+
echo "<h2>Example 1: Basic Panel</h2>\n";
26+
$basicPanel = new Panel(
27+
'Basic Panel Header', // heading
28+
'primary', // type (success|warning|info|danger|primary)
29+
'This is the panel body content.', // body
30+
'Panel footer text' // footer
31+
);
32+
echo $basicPanel->draw();
33+
34+
echo "<hr class='my-4'>\n";
35+
36+
// Example 2: Panel with HTML content
37+
echo "<h2>Example 2: Panel with HTML Content</h2>\n";
38+
$htmlPanel = new Panel();
39+
$htmlPanel->header->addItem(new H3Tag('HTML Content Panel'));
40+
$htmlPanel->body->addItem(new PTag('This panel contains HTML elements.'));
41+
$htmlPanel->body->addItem(new ATag('#', 'This is a link', ['class' => 'btn btn-info']));
42+
$htmlPanel->footer->addItem(new ButtonTag('Action Button', ['class' => 'btn btn-success']));
43+
echo $htmlPanel->draw();
44+
45+
echo "<hr class='my-4'>\n";
46+
47+
// Example 3: Panel with different types/colors
48+
echo "<h2>Example 3: Different Panel Types</h2>\n";
49+
50+
$types = ['success', 'warning', 'info', 'danger'];
51+
foreach ($types as $type) {
52+
$panel = new Panel(
53+
ucfirst($type) . ' Panel',
54+
$type,
55+
"This is a $type panel with appropriate Bootstrap coloring.",
56+
"Footer for $type panel"
57+
);
58+
echo $panel->draw();
59+
echo "<br>\n";
60+
}
61+
62+
echo "<hr class='my-4'>\n";
63+
64+
// Example 4: Panel without footer
65+
echo "<h2>Example 4: Panel Without Footer</h2>\n";
66+
$noFooterPanel = new Panel(
67+
'Panel Without Footer',
68+
'secondary',
69+
'This panel has no footer section.',
70+
null // null footer means no footer will be displayed
71+
);
72+
echo $noFooterPanel->draw();
73+
74+
echo "<hr class='my-4'>\n";
75+
76+
// Example 5: Adding items programmatically
77+
echo "<h2>Example 5: Adding Items Programmatically</h2>\n";
78+
$programmaticPanel = new Panel('Dynamic Panel');
79+
80+
// Add items to the body
81+
$programmaticPanel->addItem(new PTag('First paragraph added programmatically.'));
82+
$programmaticPanel->addItem(new PTag('Second paragraph with different content.'));
83+
$programmaticPanel->addItem('<p>You can also add raw HTML strings.</p>');
84+
85+
// You can also add to header and footer directly
86+
$programmaticPanel->footer->addItem(new PTag('Footer added after construction.', ['class' => 'text-muted']));
87+
88+
echo $programmaticPanel->draw();
89+
90+
echo "<hr class='my-4'>\n";
91+
92+
// Example 6: Empty panel that gets content conditionally
93+
echo "<h2>Example 6: Conditional Content Panel</h2>\n";
94+
$conditionalPanel = new Panel('Conditional Content');
95+
96+
$hasData = true; // This would come from your application logic
97+
98+
if ($hasData) {
99+
$conditionalPanel->addItem('<div class="alert alert-success">Data is available!</div>');
100+
$conditionalPanel->addItem('<p>Here is your data content...</p>');
101+
} else {
102+
$conditionalPanel->addItem('<div class="alert alert-info">No data available.</div>');
103+
}
104+
105+
echo $conditionalPanel->draw();
106+
107+
echo "\n</body>\n</html>";
108+
109+
/**
110+
* NOTES FOR FIXING "CardHeader not found" ERROR:
111+
*
112+
* 1. The Panel class does NOT use a separate CardHeader class
113+
* 2. Instead, it uses DivTag with 'card-header' CSS class
114+
* 3. Make sure you have the correct namespace: use Ease\TWB4\Panel;
115+
* 4. Ensure composer autoloader is properly loaded
116+
* 5. The Panel extends Card, which extends DivTag
117+
*
118+
* Common fixes:
119+
* - Check if you're trying to use \Ease\TWB4\CardHeader (which doesn't exist)
120+
* - Use \Ease\TWB4\Panel instead
121+
* - If you need just a card header, use: new \Ease\Html\DivTag($content, ['class' => 'card-header'])
122+
*
123+
* Proper usage pattern:
124+
* $panel = new \Ease\TWB4\Panel('Header Text', 'type', 'Body Content', 'Footer');
125+
* $panel->header->addItem('Additional header content');
126+
* $panel->body->addItem('Additional body content');
127+
* $panel->footer->addItem('Additional footer content');
128+
* echo $panel->draw();
129+
*/

WARP.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# WARP.md - Working AI Reference for php-ease-twbootstrap4
2+
3+
## Project Overview
4+
**Type**: PHP Project/Debian Package
5+
**Purpose**: ![Project Logo](project-logo.png?raw=true)
6+
**Status**: Active
7+
**Repository**: git@github.com:VitexSoftware/php-ease-twbootstrap4.git
8+
9+
## Key Technologies
10+
- PHP
11+
- Composer
12+
- Debian Packaging
13+
14+
## Architecture & Structure
15+
```
16+
php-ease-twbootstrap4/
17+
├── src/ # Source code
18+
├── tests/ # Test files
19+
├── docs/ # Documentation
20+
└── ...
21+
```
22+
23+
## Development Workflow
24+
25+
### Prerequisites
26+
- Development environment setup
27+
- Required dependencies
28+
29+
### Setup Instructions
30+
```bash
31+
# Clone the repository
32+
git clone git@github.com:VitexSoftware/php-ease-twbootstrap4.git
33+
cd php-ease-twbootstrap4
34+
35+
# Install dependencies
36+
composer install
37+
```
38+
39+
### Build & Run
40+
```bash
41+
dpkg-buildpackage -b -uc
42+
```
43+
44+
### Testing
45+
```bash
46+
composer test
47+
```
48+
49+
## Key Concepts
50+
- **Main Components**: Core functionality and modules
51+
- **Configuration**: Configuration files and environment variables
52+
- **Integration Points**: External services and dependencies
53+
54+
## Common Tasks
55+
56+
### Development
57+
- Review code structure
58+
- Implement new features
59+
- Fix bugs and issues
60+
61+
### Deployment
62+
- Build and package
63+
- Deploy to target environment
64+
- Monitor and maintain
65+
66+
## Troubleshooting
67+
- **Common Issues**: Check logs and error messages
68+
- **Debug Commands**: Use appropriate debugging tools
69+
- **Support**: Check documentation and issue tracker
70+
71+
## Additional Notes
72+
- Project-specific conventions
73+
- Development guidelines
74+
- Related documentation

debian/README.Debian

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,76 @@
1-
Ease framework TWB4 for Debian
2-
------------------------------
3-
1+
php-ease-twbootstrap4 for Debian
2+
=================================
43

5-
Also you can use debian package:
4+
PHP Autoloader
5+
--------------
66

7+
This package uses the **Debian PHP autoloader system** (pkg-php-tools).
8+
9+
Classes are installed in: `/usr/share/php/Ease/TWB4`
10+
Autoloader: `/usr/share/php/Ease/TWB4/autoload.php`
11+
12+
To use in your PHP code:
13+
14+
```php
15+
require_once '/usr/share/php/Ease/TWB4/autoload.php';
716
```
8-
sudo apt install php-vitexsoftware-ease-bootstrap4
9-
```
1017

18+
The autoloader is automatically generated by `phpab` during package build and
19+
includes all package classes with proper dependency loading.
20+
21+
**Note:** This package NO LONGER ships vendor/autoload.php from Composer.
22+
Use the Debian autoloader instead for proper system integration.
1123

12-
Is installed by standard way in /usr/share/php/EaseTWB4
24+
Installation
25+
------------
1326

14-
Then you can use system wide installed libraries in your package using this
15-
minimal template of composer.json
27+
For Debian, Ubuntu & friends please use repo:
1628

29+
```shell
30+
sudo apt install lsb-release wget
31+
echo "deb http://repo.vitexsoftware.cz $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list
32+
sudo wget -O /etc/apt/trusted.gpg.d/vitexsoftware.gpg http://repo.vitexsoftware.cz/keyring.gpg
33+
sudo apt update
34+
sudo apt install php-ease-twbootstrap4
1735
```
36+
37+
Composer Integration
38+
--------------------
39+
40+
If using Composer in your application, you can reference the Debian package:
41+
42+
```json
1843
{
19-
"name": "deb/your-package",
20-
"description": "App using Ease framework installed as debian package",
21-
"config": {
22-
"vendor-dir": "/var/lib/your-package"
23-
},
2444
"require": {
25-
"deb/ease-core": "*",
26-
"deb/ease-html": "*",
27-
"deb/ease-bootstrap4": "*"
45+
"deb/ease-twbootstrap4": "*"
2846
},
2947
"repositories": [
3048
{
3149
"type": "path",
32-
"url": "/usr/share/php/EaseCore",
33-
"options": {
34-
"symlink": true
35-
}
36-
},
37-
{
38-
"type": "path",
39-
"url": "/usr/share/php/EaseHtml",
40-
"options": {
41-
"symlink": true
42-
}
43-
},
44-
{
45-
"type": "path",
46-
"url": "/usr/share/php/EaseTWB4",
50+
"url": "/usr/share/php/Ease/TWB4",
4751
"options": {
4852
"symlink": true
4953
}
5054
}
5155
]
5256
}
57+
```
58+
59+
Migration from Composer vendor/autoload.php
60+
--------------------------------------------
5361

62+
If you're migrating from Composer's autoloader, replace:
63+
64+
```php
65+
require_once __DIR__ . '/../vendor/autoload.php';
5466
```
5567

68+
with:
5669

70+
```php
71+
require_once '/usr/share/php/Ease/TWB4/autoload.php';
72+
```
5773

58-
-- Vítězslav Dvořák <vitex@hippy.cz> Ne říj 21 15:17:56 CEST 2012
74+
This ensures you're using the system-wide Debian packages instead of bundled dependencies.
5975

76+
-- VitexSoftware <info@vitexsoftware.cz> Tue Mar 03 23:31:40 CET 2026

0 commit comments

Comments
 (0)