Download the PHP package rduuke/newbie without Composer
On this page you can find all versions of the php package rduuke/newbie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rduuke/newbie
More information about rduuke/newbie
Files in rduuke/newbie
Package newbie
Short Description Micro-Framework Web of PHP
License MIT
Homepage https://github.com/RDuuke/Newbie
Informations about the package newbie
Newbie
Installation:
Composer:
Configuration Files:
The file config\Config.php
data from the database is added and define the two global routes BASE_URL
and BASE_PUBLIC
.
Directory Structure:
The HTTP Layer
Route
Basic Routing:
The most basic Newbie routes simply accept a URI and a Closure, providing a very simple and expressive method of defining routes:
All Newbie routes are defined in your route files src/routes.php
.
Available Router Methods:
The router allows you to register routes that respond to any HTTP verb:
Route Parameters
Required Parameters:
Of course, sometimes you will need to capture segments of the URI within your route. For example, you may need to capture a user's ID from the URL. You may do so by defining route parameters:
Optional Parameters:
Occasionally you may need to specify a route parameter, but make the presence of that route parameter optional. You may do so by placing []; Make sure to give the route's corresponding variable a default value:
Route Groups
Route groups allow you to share route attributes , across a large number of routes without Needing to define Those attributes on each single route . Shared attributes are specified in an array format as the first parameter.
Route Controller:
Controllers:
Defining Controllers:
Below is an example of a basic controller class. Note that the controller extends the Controller class included with Newbie(Slim3/Controllers)
. The Controller class provides a few convenience,
Resource Controllers:
To use your controller REST structure , you must implement the interface ResourceController
Methods:
- index
- show($id)
- create()
- store()
- edit($id)
- update($id)
- destroy($id)
Database
Query Builder:
Capsule importing the class, we can use the query builder.
Other core methods May be Directly accessed from the Capsule in the same manner as from the DB facade :
Using The Eloquent ORM:
For further documentation on using the various database facilities this library provides, consult the Laravel framework documentation.
Views
Creating Views:
Views contain the HTML served by your application and separate your controller / application logic from your presentation logic. Views are stored in the resources/views
directory. A simple view might look something like this:
Since this view is stored at resources/views/testing.tpl.php
, we may return it using the global view helper like so:
Creating a Layouts:
To save the Repeated many times the same blocks of code in the views can be generated layout , These will be stored in the directory resource/view/layout
, A single Layout Might look something like this :
Using the design in view blog.tpl.php
Helpers
They are in the src/Tools/Helpers.php
file in this file can modify or add new helpers.
redirect:
Receives as a string with the path to the redirection.
style:
Receives as a parameter the path where is the css public/css/template.css
file, only use in the view or layout.
script:
Receives as a parameter the path where is the js public/js/template.js
file, only use in the view or layout.
route:
Get two obligatory and 2 optional parameters , are mandatory and the url link name , the two are optional data url html tag and attributes , just use viees recommended or layout. Example:
newFlashMessage:
It takes two obligatory parameters and one optional , is used to generate alerts flash.
Type:
Edit public/css/template.css
- news #01579b
- warning #ff6f00
- success #004d40
- danger #b71c1c
getFlashMessage:
which asks whether there is a warning flash with that message. returns true if otherwise false.
printFlashMessage:
which is the name of the alert to show, style alerts are the chips materialize.
arrayAdd:
Adds an item to a key value array.
arrayFirst:
He gets the first element of an array
arrayLast:
Gets the last element of an array.
arrayJson
Transforms an array to json.
jsonObject
Transforms a json to an object.
jsonArray:
Transforms a json to an array.
strLimit
It limits the number of carateres containing a string, for default is 10.
strRandom
Generates a random string of characters , according to the assigned limit, for default is 10.
Note:
Any suggestions or concerns can do in [email protected] ó @RDuuke
All versions of newbie with dependencies
filp/whoops Version ^2.1
league/plates Version ^3.1
php Version >=5.5.9
slim/slim Version ^3.0
martynbiz/slim3-controller Version ^0.0.0