dzestudio / dz-framework
DZ Estúdio 框架。
0.1.0
2013-10-24 12:32 UTC
Requires
- php: >=5.3
Requires (Dev)
- phing/phing: dev-master
- phpdocumentor/phpdocumentor: 2.1.*
- phpunit/phpunit: 3.7.*
- squizlabs/php_codesniffer: 1.*
This package is not auto-updated.
Last update: 2024-09-23 14:54:43 UTC
README
DZ 框架是由 DZ Estúdio 提供的超小 PHP 类库包。其功能包括哈希生成器和地理转换类。
组件
Dz\Security\Hash
哈希生成器类。
<?php use \Dz\Security\Hash; // Let's say that user has filled these two variables. $email = 'example@example.com'; $password = 'mYs3cR3tP4S5W0Rd!'; // Think about some reproducible salt schema... $saltBase = md5('Kynodontas#' . $email); // Now, let's hash! $hash = new Hash(array('saltBase' => $saltBase)); // Save hash somewhere. $passwordHash = $hash->crypt($password); // Now, let's check. One more time, pretend that there's an user here! $emailInput = 'example@example.com'; $passwordInput = 'wR0NgP4S5W0Rd!'; // Here is our reproducible salt schema. $saltBase = md5('Kynodontas#' . $emailInput); $hash = new Hash(array('saltBase' => $saltBase)); if ($hash->check($passwordHash, $passwordInput)) { // Hashes match :-) } else { // Something wrong... }
Dz\Maps\Converter
此类使用 Google Maps API 将地址(如“1600 Amphitheatre Parkway, Mountain View, CA”)转换为地理坐标(如纬度 37.423021 和经度 -122.083739),您可以使用这些坐标放置标记或定位地图。
示例
<?php $address = 'Rua Vinte e Quatro de Outubro, 353'; $latLng = \Dz\Maps\Converter::fromAddressToLatLng($address); echo 'Latitude: ', $latLng->lat, PHP_EOL; echo 'Longitude: ', $latLng->lng, PHP_EOL;
您还可以使用它将DMS转换为十进制。
<?php // Cachoeira do Sul DMS latitude $dmsLat = "30° 2' 54.0276'' S"; $decimalLat = \Dz\Maps\Converter::fromDmsToDecimal($dmsLat); echo 'Latitude: ', $decimalLat, PHP_EOL;