Download the PHP package r-odriguez/tusk without Composer
On this page you can find all versions of the php package r-odriguez/tusk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tusk
Tusk
A simple opinionated web library to be used alongside nginx or apache.
Installation
How to use it
Using tusk-init script
Create your project folder, open it in your terminal and run tusk-init
on it.
Setting up from scratch
Create a public folder with your index.php
there and just require it:
It ~is~ isn't necessary (anymore) to have a config.php
so tusk knows where to look for things. Usually you would define
where tusk should look for special global variables, like COMPONENTS_DIR_NAME
, which tells tusk the name of the folder that has server components for a route. This is every global variable defined by tusk and you can change it by define()
ing inside a config.php
in the root folder:
Variables | Value | Description |
---|---|---|
WEB_DIR |
"src/www" |
Directory containing web pages |
COMPONENTS_DIR_NAME |
"partials" |
Directory name for reusable components based on the route |
GLOBALS_DIR |
"src/globals" |
Directory for global components |
ICONS_DIR |
"public/svg/icons" |
Directory containing icon SVG files |
SVG_DIR |
"public/svg" |
Directory containing general SVG files |
ERROR_PAGES_DIR |
"src/www/errors" |
Directory containing error pages |
Local Development
For development I like to use php built-in web server. Create a Makefile
at the top level with the following:
You'll probably need a .env file with the following too:
Index.php example
You can use a Route
class to define the paths.
You can access :name(word)
variable using route->param("name")
function inside the controller. There are two options of creating a route: 1. the second parameter of Route->path()
is a directory inside the WEB_DIR
where there is a main.php
and a view.php
or 2. is a php file. If you choose the first option, use the tusk\view()
function to return the view inside the view.php
.
Explore the code base
If you want to know more about the library, explore the code base, is super simple. This is basically a compilation of useful functions to deal with annoyances of vanilla php.
Contributing
I don't plan on supporting this more than what I need. If you have something to add up, try your luck, I might not answer it. If I like it I'll accept probably. I accept bug reports tho.
Fixes
- [ ] Find a way to fix this:
/obj/:name(word)
would translate to$obj_name
and/prop/:name(word)
would become$prop_name
.- How the
\tusk\view()
would handle/obj/:name(word)/section
?