{"id":26251344,"url":"https://github.com/esron/php_excercises","last_synced_at":"2025-10-12T20:37:47.681Z","repository":{"id":54846895,"uuid":"293607536","full_name":"esron/php_excercises","owner":"esron","description":"PHP exercises respository","archived":false,"fork":false,"pushed_at":"2021-03-22T11:04:42.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-04T12:34:50.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-07T18:49:49.000Z","updated_at":"2021-03-22T11:04:45.000Z","dependencies_parsed_at":"2022-08-14T04:40:24.659Z","dependency_job_id":null,"html_url":"https://github.com/esron/php_excercises","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/esron/php_excercises","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esron%2Fphp_excercises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esron%2Fphp_excercises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esron%2Fphp_excercises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esron%2Fphp_excercises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esron","download_url":"https://codeload.github.com/esron/php_excercises/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esron%2Fphp_excercises/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270005591,"owners_count":24510939,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-03-13T16:52:23.981Z","updated_at":"2025-10-12T20:37:42.657Z","avatar_url":"https://github.com/esron.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Exercises\n\nIn this repository I'm gonna implement some design principles and good practices with PHP.\n\nIn the first version I'll not use any framework or library, only the default functions in PHP.\n\nFeel free to post an Issue if you think that something is not right.\n\n## Running the project\n\nEnter the `web` page and run the following comando to start the PHP development server in the port `8080`.\n\n```bash\nphp -S localhost:8080\n```\n\n## Versions\n\n### v1.0\n\nIn version v1.0 I've implemented a simple login/logout flow. The main aspects there are presented in this version are separation of responsibilities, correct level of abstraction, user input sanitization and output scaping.\n\n### v1.1\n\nIn this version I've implemented a simple support view with a form and the message history. This version emphasis form validation and session manipulation, including protection with CSRF token and user access level validation.\n\n### v2.0\n\nIn this version I've added a breaking change, now the authenticated user is fetched from the database. Also there is a view and CRUD for contacts. This version emphasis the use of a database. You will need to have a MySQL database and create two table with the following code:\n\nUsers table:\n```SQL\nCREATE TABLE `users` (\n  `id` int unsigned NOT NULL AUTO_INCREMENT,\n  `username` varchar(254) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,\n  `password` varchar(254) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,\n  `user_level` varchar(254) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'standard',\n  `signup_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `username` (`username`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\n```\n\nContacts table:\n```SQL\nCREATE TABLE `contacts` (\n  `id` int unsigned NOT NULL AUTO_INCREMENT,\n  `user_id` int unsigned NOT NULL,\n  `name` varchar(254) NOT NULL,\n  `phone` varchar(40) NOT NULL,\n  `email` varchar(254) NOT NULL,\n  `address` text NOT NULL,\n  PRIMARY KEY (`id`),\n  KEY `user_id` (`user_id`),\n  CONSTRAINT `contacts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\n```\n\nIn the development setup i've used a MySQL container with a Adminer instance, you can reproduce with the following `docker-compose.yml`:\n```yml\nversion: '3.1'\n\nservices:\n  db:\n    image: mysql:8\n    command: --default-authentication-plugin=mysql_native_password\n    restart: always\n    environment:\n      MYSQL_USER: php-user\n      MYSQL_PASSWORD: php-pass\n      MYSQL_ROOT_PASSWORD: example\n      MYSQL_ROOT_HOST: 172.*.*.*\n    volumes:\n      - ./data:/var/lib/mysql\n    ports:\n      - 3306:3306\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080\n```\n\nThe database connections is handled in the `Database` component as a singleton. The queries are madded using the `php-pdo` extension.\n\nThe authentication is handled via the `Auth` component and it is responsible for checking if the user is authenticated, return an authenticated user and set the authenticated user.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesron%2Fphp_excercises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesron%2Fphp_excercises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesron%2Fphp_excercises/lists"}