URI Library



Uri portions ( segments ) is an improved class to use. The chapters start with the first uri parameter that refers to the library in the URL, ie language expressions such as zeroneed.php or tr are not considered even if they are added to the URI.

URLs URI
  1 2 4 -1

http [s]: //

yourdomain.com/

zeroneed.php /

[Project-name /]

[Lang /]

[ controller /]

[ function /]

[ param1 /]

[ param2 /]

...

 

 

# Installation


Terminal installation command for ZN SE and ZN CE distributions.

↓ composer require znframework / package-request

 

 

# Methods


1.0.0 Stringer get ( Mixed $ get = 1 , Mixed $ index = 1 , Bool $ while = false )
3.0.0 Inter getNameCount ( String $ get )
3.0.0 Stringer getNameAll ( String $ get )
3.0.0 Stringer getByIndex ( Int $ get = 1 , Int $ index = 1 )
3.0.0 Stringer getByName ( String $ get , Scalar  $ index = NULL )
1.0.0 Array segmentArray ( Void )
1.0.0 Inter totalSegments ( Void )
1.0.0 Inter segmentCount ( Void )
1.0.0 Stringer segment ( Int $ seg = 1 )
2.0.0 Stringer currentSegment ( Void )
3.1.3 Stringer current ( Boolean $ ispath = true )
3.1.3 Stringer base ( String $ uri = '' , Int $ index = 0 )
3.1.3 Stringer prev ( Boolean $ ispath = true )
5.3.9 Stringer manipulation ( Array $ data , String $ fix = 'none' )
5.3.9 Stringer buildQuery ( Array $ data , String $ separator = '/' , String $ fix = 'none' )
5.4.5 Stringer __call ( String $ segment , Array $ parameters )

 

 

# Get ( ZN & gt; = 1.0.0 )


It is a method used to get any segment on URI, especially other pages are very successful in sending data via URI.

Uri to reach the next chapter value by using the chapter name. In other words, the first part expresses the next chapter value in order to express the key word. You can send and use key value pairs over this number of uri.

Parameters
Mixed $ get = 1 Segment name or segment index number.
Mixed $ index = 1 Which segment to take away.
Boolean $ while = false Are the intervals between 1st and 2nd parameter included in the output?
return Stringer
Use of
URL: localhost / products / detail / page / scope / content / 12
echo URI::get('content'); 
echo URI::get('products');
12
detail
Departments by Name and Number

After the chapter name, you can reach the desired chapter value according to the starting index number.

echo URI::get('products', 2);
echo URI::get('products', 3); 
page
scope
Number of Sections by Name

To know the number of the remaining part from the chapter name.

echo Uri::get('products', 'count');
5
All Departments By Name

To reach all other departments from the specified section.

echo Uri::get('products', 'all');
detail / page / scope / content / 12
Sections by Name Range

Reach other chapters, including specified chapters. To use this, parameter 3 must be set to true .

echo Uri::get('products', 'content', true);
products / detail / page / scope / content
Divisions by Name and Number

Access to uri sections by initial index number. To use this, parameter 3 must be set to true .

echo Uri::get('products', 3, true);
detail / page / scope
Chapters by Chapter Number

To get the desired sections according to chapter number.

echo Uri::get(1, 2);   
echo Uri::get(2, -1);   
echo Uri::get(2, 'all');
echo Uri::get(2, -2);     
products / detail
detail / page / scope / content / 12
detail / page / scope / content / 12
detail / page / scope / content

 

 

# GetNameCount ( ZN & gt; = 3.0.0 )


Used to find out how many segments are after the specified segment.

Parameters
Stringer $ See Segment name.
return Stringer
Use of
URL: localhost / categories / category / content
echo URI::getNameCount('categories');
2nd

 

 

# GetNameAll ( ZN & gt; = 3.0.0 )


Used to retrieve the remaining partitions after the specified segment.

Parameters
Stringer $ See Segment name.
return Stringer
Use of
URL: localhost / categories / category / content
echo URI::getNameAll('categories');
Watches / content

 

 

# GetByIndex ( ZN & gt; = 3.0.0 )


Used to get the range according to the index of the specified segment.

Parameters
Inter $ get = 1 Start segment.
Inter $ index = 1 End segment.
return Stringer
Use of
URL: localhost / categories / category / page
echo URI::getByIndex(1, 3)
echo URI::getByIndex(1, -1)
categories / category / page
categories / category / page

 

 

# GetByName ( ZN & gt; = 3.0.0 )


Used to get the range according to the specified segment names.

Parameters
Stringer $ See Start segment.
Stringer $ index = 1 End segment.
return Stringer
Use of
URL: localhost / categories / category / page
echo URI::getByName('categories', 'page');
categories / category / page

 

 

# Segment ( ZN & gt; = 1.0.0 )


There is only one parameter that is used to access any partition on the URI. Section Index

Parameters
Inter $ index = 1 Segment index.
return Stringer
Use of
URL: localhost / products / detail / page / scope / content / 1
echo Uri::segment(1);   # Output: urunler
echo Uri::segment(2);   # Output: detay
echo Uri::segment(-1);  # Output: 12

 

 

# SegmentArray ( ZN & gt; = 1.0.0 )


Returns the segments on the URI as an array.

Parameters
void
return Array
Use of
URL: localhost / products / detail / page / scope / content / 12
output(Uri::segmentArray()); 
[
    'products' ,
    'detail' ,
    'page' ,
    'scope' ,
    'content' ,
    '12'
]   

 

 

# TotalSegments ( ZN & gt; = 1.0.0 )


Returns the total number of segments on the URI.

Parameters
void
return Inter
Use of
URL: localhost / products / detail / page / scope / content / 12
output(Uri::totalSegments());
6

 

 

# CurrentSegment ( ZN & gt; = 2.0.0 )


It gives the name of the section in the URI of the currently running page.

Parameters
void
return Stringer
Use of
echo Uri::currentSegment();

 

 

# Current ( ZN & gt; = 3.1.3 )


This method performs the same function as the currentPath () function. It is used to find the URI information of the active page.

Parameters
Boolean $ isPath = true Show me the way?
return Stringer
Use of
URL: localhost / home / test
echo URI::current();
home / test

If the parameter is false , the output is as follows.

echo URI::current(false);
test

 

 

# Prev ( ZN & gt; = 3.1.3 )


This method performs the same function as the prevPath () function. It is used to find the URI information of the active page.

Parameters
Boolean $ isPath = true Show me the way?
return Stringer
Use of
URL: localhost / home / test
echo URI::prev(); # Output: home/test

If the parameter is false , the output is as follows.

echo URI::prev(false); # Output: test

 

 

# Base ( ZN & gt; = 3.1.3 )


This method is the same as using the baseUri () function. The site gives the root URI information.

Parameters
Stringer $ uri = '' URI.
return Stringer
Use of
URL: localhost / develop /
echo URI::base();            # Output: develop/ 
echo URI::base('home/test'); # Output: develop/home/test

 

 

# Manipulation ( ZN & gt; = 5.3.9 )


This method is used to manipulate parts from the URI. In doing so, it is possible to manipulate my URI without distorting it.

Parameters
Array $ data URI syntax.
Stringer $ fix = 'none' Do you get a '/' symbol at the beginning or end of the output ?
Options <span style=">199 , 37, 78 ); font-family: Menlo Monaco Consolas, monospace "> left, <span style=">199 , 37, 78 ); font-family: Menlo Monaco Consolas, monospace"> right, <span style=">199 , 37, 78 ); font-family: menlo, monaco, Consolas, monospace "> bother
return Stringer
uses
URL: localhost / user / list / order / asc / column / id / page / 10
Value Change

In the example URL above, ORDER and columna change the values.

echo URI::manipulation(['user', 'order' => 'desc', 'column' => 'name', 'page']);
user / list / order / desc / column / name / page / 10
Default Value

If the values ​​of the sections are not specified in the sequence, the first section after the relevant section is accepted as the value of that section.

echo URI::manipulation(['user', 'limit' => 5, 'page']);
User / list / limit / 5 / page / 10
Front and End Additional Use

You can insert the / symbol at the beginning, end, or both sides of the output.

echo URI::manipulation(['user', 'limit' => 5, 'page'], 'both');
/ User / list / limit / 5 / page / 10 /

 

 

# BuildQuery ( ZN> = 5.3.9 )


Used to create a URI.

Parameters
Array $ data URI syntax.
Stringer $ separator = '/' Separator.
Stringer $ fix = 'none' Do you get a '/' symbol at the beginning or end of the output ?
Options <span style=">199 , 37, 78 ); font-family: Menlo Monaco Consolas, monospace "> left, <span style=">199 , 37, 78 ); font-family: Menlo Monaco Consolas, monospace"> right, <span style=">199 , 37, 78 ); font-family: menlo, monaco, Consolas, monospace "> bother
return Stringer
uses
echo URI::buildQuery(['user' => 'list', 'order' => 'asc', 'limit', 'page']);
User / list / order / ASC / limit / page
Use of delimiters

Instead of combining array values ​​with /, you can merge them with another symbol.

echo URI::buildQuery(['user' => 'list', 'order' => 'asc', 'limit', 'page'], '-');
user-list-page-limit-order-ASC
Front and End Additional Use

You can insert the / symbol at the beginning, end, or both sides of the output.

echo URI::buildQuery(['user' => 'list', 'order' => 'asc', 'limit', 'page'], '-', 'both');
/ User-list-limit-order-ASC-page /

 

 

# __Call ( ZN & gt; = 5.4.5 )


URI :: get () method is used. The first parameter of get()method 1 is used as the method name. The use of other parameters is the same.

Use of
URL: localhost / product / computer / price / 100
echo URI::product();
computer
echo URI::price();
one hundred
echo URI::product(2);
price
Use of Segment Method

URI :: segment ()method is used. The first parameter is used as the method name. The use of other parameters is the same. There are 2 different uses. 

Capture From The Beginning

It is sxused to capture the chapter from the beginning .

echo URI::s1();
producti

Sonde Capture

It is exused to catch the section starting from the sonde .

echo URI::e1();
one hundred