{"id":19023788,"url":"https://github.com/kodriboh/bjornstad2","last_synced_at":"2025-06-11T18:33:49.156Z","repository":{"id":110642282,"uuid":"317690698","full_name":"Kodriboh/Bjornstad2","owner":"Kodriboh","description":"A simple MVC framework written using object oriented practices to make development easier. Contains advanced routing system, error handling, logging, and caching of pages for improved load speeds.","archived":false,"fork":false,"pushed_at":"2020-12-02T23:08:04.000Z","size":27,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T18:44:06.242Z","etag":null,"topics":["framework","php7"],"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/Kodriboh.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}},"created_at":"2020-12-01T23:03:13.000Z","updated_at":"2021-01-05T11:50:52.000Z","dependencies_parsed_at":"2023-03-30T12:35:13.157Z","dependency_job_id":null,"html_url":"https://github.com/Kodriboh/Bjornstad2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Kodriboh/Bjornstad2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kodriboh%2FBjornstad2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kodriboh%2FBjornstad2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kodriboh%2FBjornstad2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kodriboh%2FBjornstad2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kodriboh","download_url":"https://codeload.github.com/Kodriboh/Bjornstad2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kodriboh%2FBjornstad2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259316739,"owners_count":22839529,"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":["framework","php7"],"created_at":"2024-11-08T20:32:50.776Z","updated_at":"2025-06-11T18:33:49.067Z","avatar_url":"https://github.com/Kodriboh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bjornstad2\n## Usage\n\nBjornstad2 works as a standalone framework. Create a .env file from the .env.example, these variables are used throughout the framework via [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv).\n\nBjornstad2 can be used with the official Docker stack created specifically for projects using this framework. \nThe current stack consists of: mysql, nginx, phpmyadmin, php, composer\nmore stacks may be added in the future.\n\nYou can either simply pull this repository into your own project files or alternatively pull the [Bjornstad2 Containers](https://github.com/Kodriboh/Bjornstad2-Containers) then pull this project into the src folder.\n\nTo build the containerised project, create .env files from the .env.examples containing your environment variables and run the following command in the project root:\n\n\u003ccode\u003e\n    docker-compose up --build -d \n\u003c/code\u003e\n\n## Using Composer\n\nIf you do not have composer installed locally you can use the Bjornstad2 containers which have composer pre-installed.\n\nsimply run:\n\n\u003ccode\u003e\n    docker exec -ti php sh\n\u003c/code\u003e\n\nThen run \u003ccode\u003ecomposer install\u003c/code\u003e within the php container.\n\n## About\n\nBjornstad2 (A norse word for 'son of'), is a basic MVC framework with an advanced routing engine, error handling, and a logging system.\nBuilt on Hoegr (An older MVC framework also created by myself), Bjornstad2 is a learning framework for teaching the concepts of MVC, providing a basic\nexample of how a framework may be constructed. Unlike Hoegr, Bjornstad2 uses a more object oriented based routing system, with greater similarities to how frameworks such as Laravel function. Bjornstad2 caches pages automatically for improved load speeds.\n\n## Templating Engine\n\nBjornstad2 uses the twig templating engine. [Learn Twig](https://twig.symfony.com/doc/3.x/api.html)\n\n### Basic Twig Syntax\n\nTwig encloses renderable data in {{ }} whilst loops and conditionals are surrouned with {% %}.\n\u003cpre\u003e\n    \u003ccode\u003e\n        {{ var }}\n    \u003c/code\u003e\n    \u003ccode\u003e\n        {% for i in x %} \n            {{ i }}\n        {% endfor %}\n    \u003c/code\u003e\n\u003c/pre\u003e\n\n## Getting started\n\nTo make things easier Bjornstad2 comes with a ready made set of containers (Please see dependencies).\n\nFirst of all you will need to [install docker](https://docs.docker.com/get-docker/). \n\nSecondly, you will need to create a .env file in the root folder, adding in database requirements from the docker-compose file.\ne.g. MYSQL_PASSWORD=password\n\nNext, you will need to create a .env within the src folder, following the format of the .env.example provided.\n\nYou may then bring up your containers using: `docker-compose up --build -d`\n\nLastly you will need to install the dependencies via composer: `composer require vlucas/phpdotenv`\n\nPlease note that the php container has composer installed, if you do not have composer installed locally you can\nexec into the php container to install dependencies `docker exec -ti php sh`\n\n## Dependencies\n\n- **Docker**\n- **dotenv**\n- **mysql**\n- **PDO**\n\nBjornstad2 was built using docker WSL2 on a Windows 10 PC. \n\n## Regex\n\nRegular expressions are expressions used for advanced string matching/extracting. Regex can be used to create intricate rules in which characters can be compared and extracted to an exact pattern. This pattern matching enables complex behaviours such as extracting controller/method names from our routes.\n### Character Matching\n\nRegex patterns are written between two \"/\".\n#### Match Strings\n- /abc/ - Matches abc in any string\n\n- ^abc$ - Matches whole string \"abc\" only\n\n- a+ - Match one or more \"a\"\n\n- /abc/i - Match abc case insensitive\n\n#### Symbols\n- ^ - Match start of string\n\n- $ - Match end of string\n\n- \\* - Match zero or more\n\n- \\+ \\- Match one or more\n\n- \\. - Match any single character: letter, number or whitespace\n\n- \\ - Escape character\n\n#### Modifiers\n\n- i - Makes case insensitive\n\n#### Character Sets\n\nCharacter sets are denoted with \"[]\" this will match one\nof any characters within the brackets e.g.[abc] matches a, b, or c nothing else.\n\nHyphens can be used to specify a character range e.g. [1-5].\n\nWe cancombine this with the repetition operators:\n\n- /[a-z0-9 ]+/ - matches any sequence of alphaneumeric\ncharacters and spaces at least one character in length.\n\n### Meta Characters\nUsed to match a specific type of character/\n\n- \\d - Matches any digit 0 to 9\n\n- \\w - Matches any character from a to z, A to Z and 0 to 9\n\n- \\s - Matches any whitespace character\n\n#### Functions\n\n- preg_match($regex, $string, $matches) - matches string to regex\n\n- preg_replace($regex, $replacement, $string) - replace matching string\n\n### Capture Groups\n\nCapture Groups can be passed to regex functions which allow for it (such as preg_match). Any subpattern in parentheses will be captured as a group.\n\nNames capture groups can be used (?\u003cname\u003eregex) to retrieve items by name from the capture group array.\n\nCapture groups can be referred to using backreferences (\\1,\\2 etc...)\n\n### Examples\n\n#### Capture Group Backreference\n\n\u003ccode\u003e\n    $regex = '/ab(c)/';\n\n    $replacement = '\\lde';\n\n    $string = abc;\n\n    preg_replace($regex, $replacement, $string);\n\n    result: cde\n\u003c/code\u003e\n\n#### Named Capture Groups\n\n\u003ccode\u003e\n    /(?\u003cmonth\u003e[a-zA-Z]+) (?\u003cyear\u003e\\d+)/\n\u003c/code\u003e\n\n\n#### Replace with capture groups\n\n\u003ccode\u003e\n    $regex =  '/(\\w+) and (\\w+)/';\n\n    $replacement = '\\1 or \\2';\n\n    $string = 'Bill and Ben';\n\n    result: Bill or Ben\n\u003c/code\u003e\n\n---\n\n## Useful Resources\n\n- **[Regex](https://www.phpliveregex.com/)** \n- **[Docker](https://www.docker.com/get-started)**\n- **[LearnDocker](https://www.docker.com/play-with-docker)**\n- **[Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)**\n- **[PHPDotEnv](https://github.com/vlucas/phpdotenv)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodriboh%2Fbjornstad2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodriboh%2Fbjornstad2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodriboh%2Fbjornstad2/lists"}