{"id":20950427,"url":"https://github.com/atomgraph/core-php","last_synced_at":"2025-05-14T03:32:34.511Z","repository":{"id":147849069,"uuid":"2612537","full_name":"AtomGraph/Core-PHP","owner":"AtomGraph","description":"Generic Jena-compatible PHP Linked Data management library. Apache license.","archived":false,"fork":false,"pushed_at":"2012-03-05T10:20:05.000Z","size":414,"stargazers_count":26,"open_issues_count":19,"forks_count":4,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-16T18:33:31.611Z","etag":null,"topics":["api","linked-data","php","rdf"],"latest_commit_sha":null,"homepage":"https://atomgraph.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AtomGraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-20T11:12:31.000Z","updated_at":"2022-06-11T17:47:17.000Z","dependencies_parsed_at":"2023-03-26T14:53:18.167Z","dependency_job_id":null,"html_url":"https://github.com/AtomGraph/Core-PHP","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtomGraph%2FCore-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtomGraph%2FCore-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtomGraph%2FCore-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtomGraph%2FCore-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtomGraph","download_url":"https://codeload.github.com/AtomGraph/Core-PHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225275711,"owners_count":17448387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","linked-data","php","rdf"],"created_at":"2024-11-19T00:48:30.736Z","updated_at":"2024-11-19T00:48:31.251Z","avatar_url":"https://github.com/AtomGraph.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Requirements\n============\n\nPHP 5.3 or later. Might work on earlier PHP 5.x versions.\nJava version is in the works.\n\nDescription\n===========\n\nGraphity is a fully object-oriented PHP framework for building flexible [REST](http://en.wikipedia.org/wiki/REST)ful, [Semantic Web](http://en.wikipedia.org/wiki/Semantic_web), and/or [Linked Data](http://en.wikipedia.org/wiki/Linked_data) web applications.\n\nGraphity tries *not* to invent new conventions, but instead to combine existing ones. It is based on W3C standards and reuses Java APIs where possible.\n\nJAX-RS\n------\n\nSupports [JAX-RS](https://wikis.oracle.com/display/Jersey/Overview+of+JAX-RS+1.0+Features)-style RESTful API:\n\n* resource annotations like `@Path` and `@GET`\n* `UriBuilder` for building URIs out of components (includes implementation in JavaScript)\n* `ResponseBuilder` for building `Response` objects\n\nFurther implementation of missing JAX-RS features is planned.\n\nRDF API\n-------\n\nSupports [Jena](http://incubator.apache.org/jena/)-style object-oriented RDF API:\n\n* `Model`\n    * RDF/XML (DOM) serialization\n    * Turtle serialization\n* `Statement`\n* `Resource`\n* `Literal`\n\nUtilities\n---------\n\nIncludes utility classes for dealing with [SPARQL](http://www.w3.org/TR/sparql11-query/), [RDF/XML](http://www.w3.org/TR/REC-rdf-syntax/), and [XSLT](http://www.w3.org/TR/xslt):\n\n* `Repository` for remote SPARQL 1.1 endpoint access\n* `QueryBuilder` for building SPARQL queries\n* `RDFForm` for reading requests in [RDF/POST](http://www.lsrn.org/semweb/rdfpost.html) encoding\n* `MultipartParser` and `MultipartRequest` for reading `multipart/form-data` requests (PHP port of O'Reilly's [Multipart classes](http://www.servlets.com/cos/))\n* `XSLTBuilder` for building XSLT transformations *(PHP's [XSL extension](http://php.net/manual/en/book.xsl.php) must be enabled)*\n* `DOM2Model` for converting RDF/XML to Model (reverse of `Model::toDOM()`)\n\nUsage\n=====\n\nTo create a Graphity PHP application, you need to follow similar steps as in creating JAX-RS webapp, plus some extra steps because of PHP's interpreted and per-request nature:\n\n1.  Checkout or extract graphity-core into `/lib/graphity-core` or similar folder in your project.\n    We recommend choosing the latest version tag on GitHub.\n\n    *We strongly recommend [Maven Standard Directory Layout](http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html), as it will be easier to share reusable resources with the Java version in the future.* It is used in the following examples.\n\n2.  Create some resource class that imports and extends `Graphity\\Resource`, for example:\n\n        namespace My;\n\n        use Graphity\\Response;\n        use Graphity\\ResponseBuilder;\n        use Graphity\\View\\ContentType;\n\n        class Resource extends \\Graphity\\Resource\n\n    *We strongly recommend using PHP namespaces with the [standard folder layout](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md).* In Maven structure, that would be within the `src/main/php` folder. It is used in the following examples.\n\n3.  Annotate the class with `@Path` and methods with `@GET`/`@POST` etc., for example:\n\n        namespace My;\n\n        use Graphity\\Response;\n        use Graphity\\ResponseBuilder;\n        use Graphity\\View\\ContentType;\n\n        /**\n         * @Path(\"/hello\")\n         */\n        class Resource extends \\Graphity\\Resource\n        {\n\n            /**\n             * @GET\n             * @Produces(\"text/html\")\n             */\n            public function getResponse()\n            {\n                return ResponseBuilder::newInstance()-\u003e\n                    entity(\"\u003chtml\u003eHello \". $this-\u003egetRequest()-\u003egetParameter(\"what\") .\"!\u003c/html\u003e\")-\u003e\n                    status(Response::SC_OK)-\u003e\n                    type(ContentType::TEXT_HTML)-\u003e\n                    build();\n            }\n        }\n\n    This class would match GET requests on `/hello` path and print a statement depending on the `what` query parameter value.\n\n    *PHP annotations must be embedded in `/* */` comment blocks.*\n\n    *`@Produces`/`@Consumes` annotations are not yet fully supported, but we recommend adding them for future compatibility.*\n\n4.  Run `/lib/graphity-core/bin/route_mapper.php` specifying the root folder of your namespace and the location of your route map file, for example (paths are relative to project root in this case):\n\n        $ php lib/graphity-core/bin/route_mapper.php src/main/php/My src/main/php/routes.php\n\n    This should scan your resource classes and generate a route map file, which is used internally by Graphity to match request URIs against JAX-RS annotations.\n    *This does not happen dynamically (as of yet), you have to re-map routes with `route_mapper.php` every time your annotations change.*\n\n5. Implement a subclass of `Graphity\\Application`:\n\n        namespace My;\n\n        class Application extends \\Graphity\\Application\n        {\n\n            public function __construct()\n            {\n                parent::__construct(include(dirname(dirname(__FILE__)) . \"/routes.php\"));\n\n                $loader = new \\Graphity\\Loader(\"My\", dirname(dirname(__FILE__)));\n                $loader-\u003eregister();\n            }\n\n        }\n\n    This class initializes route map and `Graphity\\Loader` and can be used for custom initializations.\n\n6. Make an entry point to your `Application` like `index.php` and put it under `src/main/webapp`:\n\n        define('ROOTDIR', dirname(dirname(dirname(dirname(__FILE__)))));\n\n        require_once(ROOTDIR . '/lib/graphity-core/src/main/php/Graphity/Application.php');\n        require_once(ROOTDIR . '/src/main/php/My/Application.php');\n\n        $app = new My\\Application();\n        $app-\u003erun();\n\n    The `Graphity\\Application::run()` method will do the processing for you, executing the whole HTTP workflow from receiving a `Graphity\\Request` to writing out a `Graphity\\Response`.\n    Later you might want to override it with `My\\Application::run()` method to include a `try`/`catch` block for `Graphity\\WebApplicationException` handling.\n\n    *Both `Application` superclass and subclass need to be included here to bootstrap the framework.*\n\n    *This should be the single and only entry point to your Graphity web application.*\n\n7. Fix URL rewriting by adding `.htaccess` configuration under `src/main/webapp`:\n\n        RewriteEngine On\n        RewriteCond %{REQUEST_FILENAME} !-f\n        RewriteCond %{REQUEST_URI} !\\.(js|ico|gif|jpg|png|css|swf)$ [NC]\n        RewriteRule ^(.*)$ index.php/$1 [L]\n\n    *Requests with `multipart/form-data` content type should not be accessed via PHP's `$_FILE` or similar methods, and instead used with Graphity's `MultipartRequest` and `MultipartParser` classes.*\n    The following instructions make this possible by setting request content type to `multipart/form-data-alternate` before it is passed to PHP, and can be placed in `vhost.conf`:\n\n        \u003cLocation /\u003e\n            SetEnvIf Content-Type ^(multipart/form-data)(.*) NEW_CONTENT_TYPE=multipart/form-data-alternate$2 OLD_CONTENT_TYPE=$1$2\n            RequestHeader set Content-Type %{NEW_CONTENT_TYPE}e env=NEW_CONTENT_TYPE\n        \u003c/Location\u003e\n\n8. Ready? _Launch!_ Open [http://localhost/hello?what=world](http://localhost/hello?what=world) in your browser and you should see `Hello world!` printed out for you.\n*Naturally the base URI in this example depends on your webserver and/or virtual host configuration.*\n\nDocumentation\n=============\n\nWe need to do some work on this... Check out our [issues](https://github.com/Graphity/graphity-core/issues) so far.\n\nPapers \u0026 presentations\n----------------------\n\nW3C [\"Linked Enterprise Data Patterns\" workshop](http://www.w3.org/2011/09/LinkedData/)\n\n* [Graphity position paper](http://www.w3.org/2011/09/LinkedData/ledp2011_submission_1.pdf)\n* [Graphity presentation](http://semantic-web.dk/presentations/LEDP2011.pdf)\n\nLicense\n=======\n\nGraphity core is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\nLibraries\n=========\n\nGraphity PHP core uses following 3rd party libraries:\n\n1. [Addendum](http://code.google.com/p/addendum/) (for annotation parsing)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomgraph%2Fcore-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomgraph%2Fcore-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomgraph%2Fcore-php/lists"}