8grams/homie
Composer 安装命令:
composer create-project 8grams/homie
包简介
Dead simple Symfony-based framework for creating homepage
README 文档
README
Homie
Homie is a simple Symfony-based PHP framework designed specifically for creating homepages.
Normally, a homepage should have minimal features, but common PHP frameworks are quite complex because they are designed to tackle complex problems when creating web applications. Homie is different—it doesn’t aim to be a complete framework for web applications. Instead, it is designed for building simple homepages that can be installed anywhere, even on a cheap shared hosting provider.
SQLite Based
Homie relies on SQLite as the backbone of its data management, using it as a persistent database, cache, queue, and more. SQLite is an excellent RDBMS—it is fast, mature, and production-ready. Moreover, it can be installed almost anywhere, from embedded devices to large server fleets.
Dependencies
Homie is built on top of prominent open-source software to function effectively:
- SQLite as the database
- Symfony Components. Homie utilizes various Symfony Components such as http-foundation, routing, http-kernel, and more
- Redbean for database connection and ORM
- Plates as template engine
- Adminer as Database Browser
- Bedrock as Wordpress boilerplate
- Laravel Sitemap as Sitemap Generator
Usage
Prerequisites
- PHP >= 8
- Modules: php-mbstring, php-xml, php-sqlite, php-curl
Install
composer create-project 8grams/homie
Working with pages
pages directory is where we, as homepage web developers, works most of time. Homie directly maps basic URLs to the pages directory. For example, if you want to have URL like this
https://example.com/home
then, you should create a PHP file named home.php inside pages directory.
You can start coding using OG native PHP where you can mix PHP code with HTML. But for better maintainability, we recommend writing PHP code first before any HTML code.
It also handles localization quite well. All of these URLs map to home.php.
https://example.com/id/home
https://example.com/en/home
<?php
$name = "Glend";
?>
<h1>Hello, my name is <?=$name ?> </h1>
Any file you create in the pages directory has direct access to utilities such as database, cache, or http client.
<?php
// get database instance
$rb = $this->db->init();
$book = $rb->dispense('book');
$book->author = "glend";
$id = $rb->store( $book );
// set cache instance
$this->cache->set("book", $id);
?>
<p>Book created with ID <?=$id ?> </p>
Initiate
Make PHP Module for SQLite3 is already installed. For example, in Debian you install it with
sudo apt install php8.3-sqlite3 php8.3-curl php8.3-mbstring php8.3-xml
To initiate Homie, execute /admin/init path once. This path will initialize database and configure some settings
curl -v https://example.com/admin/init
Local Development
Install composer
Ref: https://getcomposer.org/download/
Run composer
composer install -vvv
Install Symfony cli
curl -sS https://get.symfony.com/cli/installer | bash
Start Symfony Dev Server
symfony server:start
Run init, by accessing init URL from browser
https://example.com/admin/init
Start coding, for getting started you can access /home
https://example.com/home
Basic Layout
By default, Homie provides 3 basic layouts, all located in the pages/layouts directory: main, navbar, and footer. main, As the name suggests, this is the main layout where all pages are attached. It is also where you can define global JavaScript and CSS scripts.
You can override navbar or footer using functions from Plates, for example
<?php
$name = "Glend";
?>
<?php $this->start('navbar') ?>
<h1>Override Navbar</h1>
<p>New Navbar</p>
<?php $this->stop() ?>
Like regular pages files, navbar and footer also have direct access to Homie's utilites like database or cache.
Components
Homie is designed with a component-based approach in mind. We chose Plates for its flexibility and extensibility, allowing us to create component-based layouts.
To create a component, add a file inside pages/components directory. You can then use it in any page file, even in the navbar or footer. For example, we create drawer.php file:
<?php
$name = "Glend";
?>
<div>
<?php $this->loadComponent('drawer') ?>
</div>
Again, like other regular page files, this component also has direct access to Homie’s utilities, such as the database, cache, and HTTP client.
Handle Request
Query parameters
https://example.com/home?name=glend&city=Surabaya
<?php
// all params
$params = $this->getQueryParams();
// specific param
$name = $this->getQueryParams("name");
?>
Form Data
curl -X POST https://example.com/home \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=glend&city=Surabaya"
<?php
// all data
$params = $this->getFormData();
// specific data
$name = $this->getFormData("city");
?>
JSON Payload
curl -X POST https://example.com/home \
-H "Content-Type: application/json" \
-d '{"name": "glend", "city": "Surabaya"}'
<?php
// all data
$params = $this->getJsonPayload();
// specific data
$name = $this->getJsonPayload("name");
?>
Migration
All migrations are located on migrations directory. To create new migration, add a file with format [order number]_[migration name].sql
touch migrations/004_create_user_table.sql
And execute /admin/migrate path
curl -v https://example.com/admin/migrate
Environment Variables
Define environment variables whether through .env file located in the root project folder, or direct inject using EXPORT command.
Localization
Homie supports localization out of the box by providing the trans function, which we can access from the pages with en as default language. For example:
<?php
?>
<p><?= $this->trans('home', 'Rumah') ?></p>
The later arguments is optional and return empty string if Homie cannot handle it. To set default language, use DEFAULT_LANG values from .env.
There are two ways to work with translations. The first is using lang JSON files which is located on src/lang. The second is, insert data into the translations table with the schema name, locale, and value. For example, the SQL should be:
INSERT INTO translations (label, value, locale) VALUES ("home", "Home", "en")
Accessing pages with localization
Attach the language you want to use in the URL as the first path segment. For example:
https://example.com/id/home
https://example.com/en/home
Dynamic Pages
Sometimes, we need a way to handle dynamic URLs or slugs. The best example of this is a blog. Let's say you have a blog, and to access a blog post, you want a URL like https://example.com/blog/blog-title, where blog-title is often a slug version of the blog's title.
To handle this, Homie uses a special file named slug.php. Homie checks the URL, and if the path cannot be mapped to a file in a folder, it will check whether slug.php exists. If slug.php is present, Homie will use that file to handle the request.
In slug.php, you can access the slug using $this->slug.
Wordpress Integration
WordPress is incorporated into Homie out of the box and will be installed in the /wp folder. The installed WordPress already uses SQLite as its default database for persistence, and alos caching and multi languages plugins.
The WordPress that will be installed comes from 8grams's Bedrock, a custom Bedrock WordPress forked from roots/bedrock. It enables Homie to install WordPress along with its plugins through Composer.
To enable WordPress in Homie, simply set BLOG_ENGINE=wordpress in the .env file, and run
composer install
Content Customization
Copywriting and images can be customized using the special functions $this->trans and $this->asset. Take a look at pages/index.php for a glimpse of this feature.
<section class="header">
<p align="center">
<img data-asset="homie_logo" alt="Homie" src=<?= $this->asset('homie_logo', 'https://raw.githubusercontent.com/8grams/homie/refs/heads/develop/assets/logo.png')?> height="150">
</p>
</section>
<section class="readme">
<h2 data-trans='welcome'><?= $this->trans('welcome', 'Welcome to Homie') ?></h2>
<p data-trans="welcome_description"><?= $this->trans('welcome_description', 'Homepage should have minimal features, but common PHP frameworks are quite complex because they are designed to tackle complex problems when creating web applications. Homie is different, it is designed for building simple homepages that can be installed anywhere, even on a cheap shared hosting provider.') ?></p>
</section>
To customize the content, open the Admin Dashboard. You'll notice that all content wrapped with the data-trans and data-asset attributes can be easily customized.
Sitemap
A sitemap can be generated using the following command:
composer run generate-sitemap
This will automatically generate a sitemap by crawling your website. To enable this feature, ensure that the correct value is set in the .env file:
APP_URL=https://example.com
sitemap.xml will be generated in the public/sitemap.xml and can be accessed on https://example.com/sitemap.xml
Note: This sitemap feature in the framework is made possible by modifying Spatie's Laravel Sitemap library. Check on https://github.com/spatie/laravel-sitemap
Admin Dashboard
The admin panel can be accessed through /admin. The login username and password are defined in the .env file by setting the ADMIN_USERNAME and ADMIN_PASSWORD values.
Demo
Link: https://homie.8grams.tech/admin Username: admin Password: admin
Adminer
Adminer is already integrated into Homie Admin and can be accessed at /_admin/adminer.
Send Email
Email templates should be placed in the pages/emails directory. Homie provides three basic email layouts—main, header, and footer—all located in pages/emails/layouts.
To send an email, you can call $this->mailer->send($options, $data, $template) from any page file, as shown below:
<?php
$this->mailer->send([
'to' => 'example@gmail.com',
'from' => 'no-reply@example.com',
'subject' => 'Welcome to Homie',
], [
'userName' => 'John Doe',
'homieUrl' => 'https://homie.com',
],
'welcome'
);
?>
Make sure to correctly set MAILER_DSN in the .env file and have an email template ready. In this example, the template welcome.php should be placed in pages/emails.
Homie supports both an HTML version (welcome.php) and a plain text version (welcome.plain.php) for the email body.
Upgrading
Upgrading is easy. Run:
composer run upgrade
Then, check the final result to ensure that no unwanted files have been modified or added.
License
MIT
8grams/homie 适用场景与选型建议
8grams/homie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「homepage」 「homie」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 8grams/homie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 8grams/homie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 8grams/homie 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Avoid deleting pages that have children or are the home page of your website.
Mein Kontaktformular mit Verarbeitungscode
Base bootstrap templates for Suilven homepage and landing page
Zum erstellen und verwalten von Modulen
Adds a homepage and landing page for template override and additional functionality
Neues Package für Rezensionen
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-10
