{"id":20709549,"url":"https://github.com/pernillasterner/php_note_app","last_synced_at":"2026-04-11T18:02:48.993Z","repository":{"id":262963074,"uuid":"888519013","full_name":"pernillasterner/php_note_app","owner":"pernillasterner","description":"A simple note application. ","archived":false,"fork":false,"pushed_at":"2024-11-25T16:26:12.000Z","size":99,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"development","last_synced_at":"2025-06-03T19:16:22.651Z","etag":null,"topics":["authentication","composer","controllers","crud","login-form","middleware","mysql","php","registration-form","router","session","sql","tailwindcss","validation","views"],"latest_commit_sha":null,"homepage":"","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/pernillasterner.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-14T14:38:37.000Z","updated_at":"2024-11-25T20:30:55.000Z","dependencies_parsed_at":"2025-05-27T10:48:43.367Z","dependency_job_id":null,"html_url":"https://github.com/pernillasterner/php_note_app","commit_stats":null,"previous_names":["pernillasterner/php_note_app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pernillasterner/php_note_app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pernillasterner%2Fphp_note_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pernillasterner%2Fphp_note_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pernillasterner%2Fphp_note_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pernillasterner%2Fphp_note_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pernillasterner","download_url":"https://codeload.github.com/pernillasterner/php_note_app/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pernillasterner%2Fphp_note_app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31689762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["authentication","composer","controllers","crud","login-form","middleware","mysql","php","registration-form","router","session","sql","tailwindcss","validation","views"],"created_at":"2024-11-17T02:06:52.804Z","updated_at":"2026-04-11T18:02:48.967Z","avatar_url":"https://github.com/pernillasterner.png","language":"PHP","readme":"# Mini Note App\n\nA simple note application.\n\n___\n\n### Fetching data from db using `fetchAll` method\n\nThe `fetchAll` method retrieves all rows from a query result set and returns them as an array of associative arrays.\n\n___\n\n```php\n$notes = $db-\u003equery('select * from notes where user_id = 1')-\u003efetchAll();\n```\n\n#### Results\n\n`fetchAll`: This method fetches all rows of a query result and returns them in a structured format.\n\n```php\narray(1) {\n  [0]=\u003e\n  array(3) {\n    [\"id\"]=\u003e\n    int(1)\n    [\"body\"]=\u003e\n    string(31) \"Let's go!\"\n    [\"user_id\"]=\u003e\n    int(1)\n  }\n}\n```\n\n___\n\n\n### Status codes\n\n- 403 Forbidden\n- 404 Page Not Found\n\n\n___\n\n\n\n### Functions\n\nCreating custom functions to simplify common tasks. 📁\n\nThis function checks condition if the user is authorized, and if the condition fails, it aborts the process with a given status code. \n\n```php\nauthorize($note['user_id'] !== $currentUserId);\n\n// Make it possible to overwrite status code\nfunction authorize($condition, $status = Response::FORBIDDEN)\n{\n    // Status code 403 - Forbidden\n    if (! $condition) {\n        abort($status);\n    }\n}\n```\n\n\n___\n\n\n\n### POST and GET Methods\n\n- `$_POST` = Use for sending sensitive information. Sends data behind the scenes.\n- `$_GET` = Use for sharing or fetching data where visibility isn´t a problem. Sends data via query string in the URL.\n\n___\n\n\n### Simplifying Null Coalescing in PHP\n\n\n##### Example 1: Traditional Ternary Operator\n```php\n// You can do this OR \n\u003c?= isset($_POST['body']) ? $_POST['body'] : '' ?\u003e\n```\n\n##### Example 2: Null Coalescing Operator (PHP 7+)\nIf $_POST['body'] exists and is not null, its value is returned; otherwise, an empty string is used.\n\n```php\n// You can do this PHP 7+\n\u003c?= $_POST['body'] ?? '' ?\u003e\n```\n\n___\n\n\n### compact()\n\nCreates an associative array where the keys are the names of the given variables ('method', 'uri', 'controller'), and the values are the corresponding variable values.\n\n\n```php\n  public function add($method, $uri, $controller)\n    {\n        $this-\u003eroutes[] = compact('method', 'uri', 'controller');\n    }\n```\n\n___\n\n\n### Middleware\n\nMiddleware is software that lies between an operating system and the application running on it. \n\n```php\n\n// Applying middleware to the route\n        $this-\u003eroutes[array_key_last($this-\u003eroutes)]['middleware'] = $key;\n\n// Results\n  array(4) {\n    [\"method\"]=\u003e\n    string(3) \"GET\"\n    [\"uri\"]=\u003e\n    string(9) \"/register\"\n    [\"controller\"]=\u003e\n    string(35) \"controllers/registration/create.php\"\n    [\"middleware\"]=\u003e\n    string(5) \"guest\"\n  }\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpernillasterner%2Fphp_note_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpernillasterner%2Fphp_note_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpernillasterner%2Fphp_note_app/lists"}