Download the PHP package 8grams/homie without Composer
On this page you can find all versions of the php package 8grams/homie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package homie
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
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
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.
Any file you create in the pages directory has direct access to utilities such as database, cache, or http client.
Initiate
Make PHP Module for SQLite3 is already installed. For example, in Debian you install it with
To initiate Homie, execute /admin/init path once. This path will initialize database and configure some settings
Local Development
Install composer
Ref: https://getcomposer.org/download/
Run composer
Install Symfony cli
Start Symfony Dev Server
Run init, by accessing init URL from browser
Start coding, for getting started you can access /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
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:
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
Form Data
JSON Payload
Migration
All migrations are located on migrations directory. To create new migration, add a file with format [order number]_[migration name].sql
And execute /admin/migrate path
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:
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:
Accessing pages with localization
Attach the language you want to use in the URL as the first path segment. For example:
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
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.
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:
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:
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:
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:
Then, check the final result to ensure that no unwanted files have been modified or added.
License
MIT
All versions of homie with dependencies
symfony/routing Version ^7.2
symfony/dependency-injection Version ^7.2
symfony/cache Version ^7.2
symfony/http-kernel Version ^7.2
symfony/http-client Version ^7.2
symfony/dotenv Version ^7.2
league/plates Version ^3.6
symfony/security-core Version ^7.2
spatie/ignition Version ^1.15
nesbot/carbon Version ^3.8
symfony/dom-crawler Version ^7.2
spatie/crawler Version ^8.4
guzzlehttp/guzzle Version ^7.9
symfony/mailer Version ^7.2
aws/aws-sdk-php Version ^3.342