safronik/globals 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

safronik/globals

最新稳定版本:0.1.2

Composer 安装命令:

composer require safronik/globals

包简介

Helper to receive global variables

README 文档

README

A PHP library to ease gaining of PHP global variables

About

This package is about convenient way to operate global variables. It's include few classes to achieve that:

  • Server
  • Request
  • Cookie
  • Get
  • Post

Installation

The preferred method of installation is via Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

composer require safronik/globals

or just download files or clone repository (in this case you should bother about autoloader)

Usage

This class caches the values in its own Multiton storage, to prevent multiple filtration.

Gain variable value

You can get any of those by simply call:

$get_variable = Get::get('some_Get_variable');
$get_variable = Post::get('some_Post_variable');
$get_variable = Cookie::get('some_Cookie_variable');
$get_variable = Server::get('some_Server_variable');
$get_variable = Request::get('some_Request_variable');

Server

Server class has the method getHTTPHeaders(). It will return all the variables in SERVER starts with 'http_' (case insensitive).

$http_headers = Server::getHTTPHeaders();

Cookie

Cookie class can also helpful to set a cookie header, unless the headers are sent.

$expires   = 0; 
$path      = ''; 
$domain    = 'some.domain'; 
$secure    = true; 
$http_only = true; 
$same_site = 'Lax'; 

$http_headers = Cookie::set(
    'cookie_name',
    'cookie_value',
    $expires,
    $path,
    $domain,
    $secure,
    $http_only,
    $same_site,
);

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-18