Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jplhomer/fresa
🍓 Developing WordPress should be sweet.
https://github.com/jplhomer/fresa
developer-tools fluent-interface wordpress
Last synced: 3 months ago
JSON representation
🍓 Developing WordPress should be sweet.
- Host: GitHub
- URL: https://github.com/jplhomer/fresa
- Owner: jplhomer
- Created: 2017-08-11T02:44:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-13T20:43:27.000Z (over 4 years ago)
- Last Synced: 2024-10-25T03:52:57.217Z (3 months ago)
- Topics: developer-tools, fluent-interface, wordpress
- Language: PHP
- Homepage: https://fresa.jplhomer.org
- Size: 85.9 KB
- Stars: 45
- Watchers: 4
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fresa
**🍓 Developing WordPress should be sweet.**
Use [Fresa](https://fresa.jplhomer.org) in your plugins and themes to make interacting with the WordPress ecosystem friendly and fast.
Tested on **WordPress 4.8** and requires **PHP 7+**. Your mileage may vary.
```php
use Fresa\PostModel;class Event extends PostModel
{
$postType = 'my_custom_post_type';
}
```Register your custom post types in one line:
```php
Event::register();
```Interact with your post in an object-oriented fashion:
```php
$event = new Event;
$event->title = 'Hello World.';
$event->venue = 'Times Square';
$event->save();echo $event->id; // 1
echo $event->venue; // 'Times Square';
// Same as get_post_meta(1, 'venue', true);
```And perform queries through a fluent interface:
```php
$event = Event::find(1);
$events = Event::where('venue', 'Times Square')
->order('date', 'asc')
->limit(5)
->offset(5)
->get();
```Queries return a [Collection instance](https://laravel.com/docs/5.4/collections):
```php
$events->each(function($event) {
echo $event->title;
});
```## Installation
```sh
composer require jplhomer/fresa
```**[Read the full documentation here](https://fresa.jplhomer.org)**.
## Development
```sh
composer install
```### Running Tests
First, set up the required WordPress testing library on your machine:
```bash
# Replace db-name, db-user, db-pass with arguments of a database to be created
# If you already have a database, pass `true` to the last argument, e.g.
# wptests root '' 127.0.0.1 latest true
./bin/install-wp-tests.sh [db-host] [wp-version] [skip-database-creation]
```Run tests using PHPUnit:
```bash
vendor/bin/phpunit
```