carbonorm / carbonphp
A PHP 8.1+ tool kit featuring RESTFUL ORM, sockets, session management, and routing.
Requires
- php: >=8.3
- ext-curl: *
- ext-fileinfo: *
- ext-json: *
- ext-openssl: *
- ext-pcntl: *
- ext-pdo: *
- ext-posix: *
- ext-readline: *
- ext-sockets: *
- ext-zip: *
- mustache/mustache: ^v2.14.2
- psr/log: 1.1.4
Requires (Dev)
- phpmetrics/phpmetrics: >=2.7
- phpunit/phpunit: >=9.5
- phpunit/phpunit-selenium: >=9.0.1
- richardtmiles/php-git-hooks: dev-main
- se/selenium-server-standalone: >=3.141.59
- dev-lts
- 20.5.9
- 20.5.8
- 20.5.7
- 20.5.6
- 20.5.5
- 20.5.4
- 20.5.3
- 20.5.2
- 20.5.1
- 20.5.0
- 20.4.3
- 20.4.2
- 20.4.1
- 20.4.0
- 20.3.19
- 20.3.18
- 20.3.17
- 20.3.16
- 20.3.15
- 20.3.14
- 20.3.13
- 20.3.12
- 20.3.11
- 20.3.10
- 20.3.9
- 20.3.8
- 20.3.7
- 20.3.6
- 20.3.5
- 20.3.4
- 20.3.3
- 20.3.2
- 20.3.1
- 20.3.0
- 20.2.0
- 20.1.9
- 20.1.8
- 20.1.7
- 20.1.6
- 20.1.5
- 20.1.4
- 20.1.3
- 20.1.2
- 20.1.1
- 20.1.0
- 20.0.0
- 19.2.6
- 19.2.5
- 19.2.4
- 19.2.3
- 19.2.2
- 19.2.1
- 19.2.0
- 19.1.0
- 19.0.15
- 19.0.14
- 19.0.13
- 19.0.12
- 19.0.11
- 19.0.10
- 19.0.9
- 19.0.8
- 19.0.7
- 19.0.6
- 19.0.5
- 19.0.4
- 19.0.3
- 19.0.2
- 19.0.1
- 19.0.0
- 18.1.1
- 18.1.0
- 18.0.8
- 18.0.7
- 18.0.6
- 18.0.5
- 18.0.4
- 18.0.3
- 18.0.2
- 18.0.1
- 18.0.0
- 17.1.3
- 17.1.2
- 17.1.1
- 17.1.0
- 17.0.0
- 16.0.0
- 15.1.2
- 15.1.1
- 15.1.0
- 15.0.2
- 15.0.1
- 15.0.0
- 14.7.8
- 14.7.7
- 14.7.6
- 14.7.5
- 14.7.4
- 14.7.3
- 14.7.2
- 14.7.1
- 14.7.0
- 14.6.9
- 14.6.8
- 14.6.7
- 14.6.6
- 14.6.5
- 14.6.4
- 14.6.3
- 14.6.2
- 14.6.1
- 14.6.0
- 14.5.5
- 14.5.4
- 14.5.3
- 14.5.2
- 14.5.1
- 14.5.0
- 14.4.9
- 14.4.8
- 14.4.7
- 14.4.6
- 14.4.5
- 14.4.4
- 14.4.3
- 14.4.2
- 14.4.1
- 14.4.0
- 14.3.9
- 14.3.8
- 14.3.7
- 14.3.6
- 14.3.5
- 14.3.4
- 14.3.3
- 14.3.2
- 14.3.1
- 14.3.0
- 14.2.9
- 14.2.8
- 14.2.7
- 14.2.6
- 14.2.5
- 14.2.4
- 14.2.3
- 14.2.2
- 14.2.1
- 14.2.0
- 14.1.9
- 14.1.8
- 14.1.7
- 14.1.6
- 14.1.5
- 14.1.4
- 14.1.3
- 14.1.2
- 14.1.1
- 14.1.0
- 14.0.9
- 14.0.8
- 14.0.7
- 14.0.6
- 14.0.5
- 14.0.4
- 14.0.3
- 14.0.2
- 14.0.1
- 14.0.0
- 13.9.9
- 13.9.8
- 13.9.7
- 13.9.6
- 13.9.5
- 13.9.4
- 13.9.3
- 13.9.2
- 13.9.1
- 13.9.0
- 13.8.9
- 13.8.8
- 13.8.7
- 13.8.6
- 13.8.5
- 13.8.4
- 13.8.3
- 13.8.2
- 13.8.1
- 13.8.0
- 13.7.9
- 13.7.8
- 13.7.7
- 13.7.6
- 13.7.5
- 13.7.4
- 13.7.3
- 13.7.2
- 13.7.1
- 13.7.0
- 13.6.9
- 13.6.8
- 13.6.7
- 13.6.6
- 13.6.5
- 13.6.4
- 13.6.3
- 13.6.2
- 13.6.1
- 13.6.0
- 13.5.9
- 13.5.8
- 13.5.7
- 13.5.6
- 13.5.5
- 13.5.4
- 13.5.3
- 13.5.2
- 13.5.1
- 13.5.0
- 13.4.6
- 13.4.5
- 13.4.4
- 13.4.3
- 13.4.2
- 13.4.1
- 13.4.0
- 13.3.9
- 13.3.8
- 13.3.7
- 13.3.6
- 13.3.5
- 13.3.4
- 13.3.3
- 13.3.2
- 13.3.1
- 13.3.0
- 13.2.1
- 13.2.0
- 13.1.8
- 13.1.7
- 13.1.6
- 13.1.5
- 13.1.3
- 13.1.2
- 13.1.1
- 13.1.0
- 13.0.7
- 13.0.6
- 13.0.5
- 13.0.4
- 13.0.3
- 13.0.2
- 13.0.1
- 13.0.0
- 12.4.4
- 12.4.3
- 12.4.2
- 12.4.1
- 12.4.0
- 12.3.9
- 12.3.8
- 12.3.7
- 12.3.6
- 12.3.5
- 12.3.4
- 12.3.3
- 12.3.2
- 12.3.1
- 12.3.0
- 12.2.9
- 12.2.8
- 12.2.7
- 12.2.5
- 12.2.4
- 12.2.3
- 12.2.1
- 12.2.0
- 12.1.4
- 12.1.3
- 12.1.2
- 12.1.1
- 12.1.0
- 12.0.9
- 12.0.8
- 12.0.7
- 12.0.6
- 12.0.5
- 12.0.4
- 12.0.3
- 12.0.2
- 12.0.1
- 12.0.0
- 11.3.6
- 11.3.5
- 11.3.4
- 11.3.3
- 11.3.2
- 11.3.1
- 11.3.0
- 11.2.9
- 11.2.8
- 11.2.7
- 11.2.6
- 11.2.5
- 11.2.4
- 11.2.3
- 11.2.2
- 11.2.1
- 11.2.0
- 11.1.9
- 11.1.8
- 11.1.7
- 11.1.6
- 11.1.5
- 11.1.4
- 11.1.3
- 11.1.2
- 11.1.1
- 11.1.0
- 11.0.9
- 11.0.8
- 11.0.7
- 11.0.6
- 11.0.5
- 11.0.4
- 11.0.3
- 11.0.2
- 11.0.1
- 11.0.0
- 10.9.9
- 10.9.8
- 10.9.7
- 10.9.6
- 10.9.5
- 10.9.4
- 10.9.3
- 10.9.2
- 10.9.1
- 10.9.0
- 10.8.9
- 10.8.8
- 10.8.7
- 10.8.6
- 10.8.5
- 10.8.4
- 10.8.3
-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 9.1.7
- 9.1.6
- 9.1.5
- 9.1.4
- 9.1.3
- 9.1.2
- 9.1.1
- 9.1.0
- 9.0.9
- 9.0.8
- 9.0.7
- 9.0.6
- 9.0.5
- 9.0.4
- 9.0.3
- 9.0.2
- 9.0.1
- 9.0.0
- 8.2.8
- 8.2.7
- 8.2.6
- 8.2.5
- 8.2.4
- 8.2.3
- 8.2.2
- 8.2.1
- 8.2.0
- 8.1.6
- 8.1.5
- 8.1.4
- 8.1.3
- 8.1.2
- 8.1.1
- 8.1.0
- 8.0.7
- 8.0.6
- 8.0.5
- 8.0.4
- 8.0.3
- 8.0.2
- 8.0.1
- 8.0.0
- 7.5.1
- 7.5.0
- 7.4.2
- 7.4.1
- 7.4.0
- 7.3.3
- 7.3.2
- 7.3.1
- 7.3.0
- 7.2.1
- 7.2.0
- 7.1.0
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.7.1
- 6.7.0
- 6.5.5
- 6.5.4
- 6.5.2
- 6.5.1
- 6.4.1
- 6.4.0
- 6.3.4
- 6.3.3
- 6.3.2
- 6.3.1
- 6.3.0
- 6.2.1
- 6.1.0
- 6.0.0
- 5.0.2
- 5.0.1
- 5.0.0
- 4.9.0
- 4.5.0
- 4.1.1
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.2
- 3.1.1
- 3.0.0
- 2.1.0
- 2.0.0
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/es5-ext-0.10.64
- dev-version20
- dev-RichardTMiles-patch-2
- dev-RichardTMiles-patch-1
- dev-restNamespacePrefixBugfix
- dev-master
- dev-RestUpdate_PrimaryKeyValidation
This package is auto-updated.
Last update: 2024-12-19 23:16:28 UTC
README
Welcome to CarbonPHP
Our full documentation is available at our GitHub Wiki or with runnable examples at Carbonorm.dev.
Installation
composer require carbonorm/carbonphp
This command will install the latest release of CarbonPHP using Composer. If you do not already have Composer installed,
you may do so by following the instructions at getcomposer.org. Composer is PHP's
package manager, and is required to use CarbonPHP. Packagist
is the official repository for Composer packages, and is where download statistics are gathered from. The old repository location composer require richardtmiles/carbonphp
will still work with composer/packagist, but it is reccomended to move to the new location. The total number # of downloads above is duplicated to refect the two ways to download via composer.
Wordpress
Alternatively, you may install CarbonPHP as a WordPress Plugin. This will allow you to use CarbonPHP's features with a guided user interface.
CarbonPHP Tool Kit and Performance Library
CarbonPHP has grown into the CarbonORM Public Organization. There you can find documentation over the front end process of using the ORM. C6 now refers to any of Carbon* prefixed CarbonORM packages.
CarbonPHP has reached a stable level of trust in its own features through PHPUnit Tests + GitHub Actions but is still in active development. CarbonPHP is being used in production environments. Anyone, or team, who attempts using this code will find support on GitHub through issues and forums. We generally expect any issue you many encountered to be minor. If you edit the codebase, please consider submitting those changes on GitHub! C6 uses Semantic Versioning 2.0.0. Generally: MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards compatible manner, and PATCH version when you make backwards compatible bug fixes. Changes to function/class/etc will be called out in the Changelog with every minor release. Please read the changelog or code changes carefully when updating. Refer to the guide at carbonphp.com
Introduction - { MySQL ORM ∪ WebSockets ∪ $_SESSION Management ∪ PDO Database Management }
CarbonPHP is a PHP 8.2+ library to simplify the building of custom, dynamic web applications. Its main focus is to make webapps run ridiculously fast, with performance and high-traffic scalability being the absolute highest concern. CarbonPHP has clocked in with impressive statistics, sometimes doubling the traffic that small servers with MySQL-intensive sites can handle. C6 works as a standalone backbone for your dev needs or in the corporation with other popular frameworks like WordPress or Laravel.
CarbonPHP's other goals include portability; allowing your webapps to be installed on servers with different operating systems (Windows, Mac, and Linux Support). Full MySQL ORM REST generator, and php written database tools designed around the MySQL. Windows PHP currently lacks a library capable of forking. Should your development require a Windows computers look into WSL. I hope to contribute a php library written in C (PHP is written in C) to support this task, however time is a factor. Should you feel compelled to help in this goal please contact me at Richard@Miles.Systems. Please see the documentation at Carbonphp.com for more information. For the rest of us who live outside windows Hell C6 has a Websocket Library Class for Standard use and WordPress use.
Quick Start
Existing projects
composer require carbonorm/carbonphp
Standards
C6 should follow the PHP Standards Recommendations listed below.
Requirements
CarbonPHP currently requires PHP 8.2 or later. We try to stay up-to-date with PHP's Supported Versions. It makes use of return type object notation, and should not be ported back to earlier PHP versions. CarbonPHP will always try to stay upto date with the latest version of PHP. Use of an opcode cache such as XCache is highly recommended, as Carbon is able to run entirely without stat() calls when paired with an opcode cache. Also recommended (but optional) is a RAM-caching engine such as memcached. PHP8, if not already supported, will receive support WITH C6's FIRST Backwards Compatible Release. Plans to drop 7.4 are currently scheduled for the summer of 2022.
Documentation
All function should have PHPDoc-style documentation in the code. CarbonPHP.com also has full explanations of the codebase. ssed to MVC. Please ensure your namespace mappings are correct!";
RESTFUL ORM
CarbonPHP's largest feature is the MySQL ORM. By running a customizable CLI command our program will analyze your database schema and generate powerful classes used to manipulate your tables. The auto generated files may be used in conjunction for an incredibly pleasing RESTFUL semantics structure. Below are examples for using the REST ORM. You can see the generated source here.
<?php $id = Users::Post([ Users::USER_TYPE => 'Athlete', Users::USER_IP => '127.0.0.1', Users::USER_SPORT => 'GOLF', Users::USER_EMAIL_CONFIRMED => 1, Users::USER_USERNAME => Config::ADMIN_USERNAME, Users::USER_PASSWORD => Config::ADMIN_PASSWORD, Users::USER_EMAIL => 'richard@miles.systems', Users::USER_FIRST_NAME => 'Richard', Users::USER_LAST_NAME => 'Miles', Users::USER_GENDER => 'Male' ]);
Joining across multiple tables.
Users::Get($user, $uid, [ Users::SELECT => [ Users::USER_USERNAME, Carbon_Locations::STATE ], Users::JOIN => [ Users::INNER => [ Carbon_Location_References::TABLE_NAME => [ Users::USER_ID => Carbon_Location_References::ENTITY_REFERENCE ], Carbon_Locations::TABLE_NAME => [ Carbon_Locations::ENTITY_ID => Carbon_Location_References::LOCATION_REFERENCE ] ] ], Users::PAGINATION => [ Users::LIMIT => 1, Users::ORDER => [Users::USER_USERNAME => Users::ASC] ] ]);
Using the ORM from the Frontend. This example showcases multiple table joins, as well as the use of aggregate function( s) GROUP_CONCAT.
const {axios} = this.props; axios.get('/rest/' + C6.carbon_users.TABLE_NAME, { params: { [C6.SELECT]: [ C6.carbon_users.USER_USERNAME, C6.carbon_users.USER_FIRST_NAME, C6.carbon_users.USER_LAST_NAME, C6.carbon_users.USER_ID, [C6.GROUP_CONCAT, C6.carbon_features.FEATURE_CODE], [C6.GROUP_CONCAT, C6.carbon_groups.GROUP_NAME] ], [C6.JOIN]: { [C6.LEFT]: { [C6.carbon_user_groups.TABLE_NAME]: [ C6.carbon_users.USER_ID, C6.carbon_user_groups.USER_ID ], [C6.carbon_groups.TABLE_NAME]: [ C6.carbon_user_groups.GROUP_ID, C6.carbon_groups.ENTITY_ID ], [C6.carbon_feature_group_references.TABLE_NAME]: [ C6.carbon_groups.ENTITY_ID, C6.carbon_feature_group_references.GROUP_ENTITY_ID ], [C6.carbon_features.TABLE_NAME]: [ C6.carbon_features.FEATURE_ENTITY_ID, C6.carbon_feature_group_references.FEATURE_ENTITY_ID ] } }, [C6.PAGINATION]: { [C6.LIMIT]: 100 } } }).then(response => this.setState({users: (response.data.rest || [])}));
Builtin Command Line Interface
Much like laravel's artisan, any file that invokes CarbonPHP from the command line will execute the CLI Interface. I plan to make a system in place for user commands in Beta. See all available commands with:
php index.php help
Support
Support for CarbonPHP is offered at https://github.com/RichardTMiles/CarbonPHP.
Legal
Use of CarbonPHP implies agreement with its software license, available in the LICENSE file. This license is subject to change from release to release, so before upgrading to a new version of C6, please review its license.
Credits
CarbonPHP was created by Richard Tyler Miles, the BDFL, and inspired by Tom Frost's Hydrogen.
Contributors can be found on the contributors page.
TODO - Double down on apache configs
https://gist.github.com/RichardTMiles/ae5718aff63ab4633457b6285c825aa2 This will be in CarbonWordPress and modified for general use in CarbonPHP.