Syngr : SYNtactic suGaR
This project is an effort to consolidate PHP's wildly varying functions, and provide some sort of Standard Library for it.
The idea is to make programming in PHP simpler, and force it to behave in a more predictable manner. Most, if not all, methods for these types all operate on the object itself, which gives us a nice side-benefit of being able to chain multiple methods on an object.
$string = new String('hello world');
echo $string->uppercase() // HELLO WORLD
->substring(0, 6) // HELLO
->replace(' ', '?') // HELLO?
->trim('?'); // HELLO
join()
split()
match()
hash($algorithm_name)
where $algorithm_name can be anything from [here](http://www.php.net/manual/en/function.hash.php).
bcrypt($cost)
where $cost is an integer between 4 and 31
substring($start, $length)
where $start is the index to start the substring and $length is the length of the substring.
trim()
uppercase()
lowercase()
pad()
length()
reverse()
replace()
$number = new Number(6.9);
echo $number->ceiling() // 7
->max(array(5, 9, 49.1)) // 49.1
->floor() // 49
->sqrt() // Value
->value(); // Get raw value rather than string
absolute()
ceiling()
floor()
round()
max()
min()
sqrt()
convert()
random()
exp()
log()
pow()
cos()
sin()
tan()
Clone the project somewhere, cd
to the directory and type in composer install
.
Syngr's dependencies are listed in the composer.json
file, but if you're installing as a user then it has no extra dependencies (whoop!).
The best way to see Syngr in action is to look at the test code // Add an examples folder.
Run phpunit
from the terminal in the project folder to run unit tests.
- Run other local services / provide credentials for external services.
rake spec:integration
From the project folder, type in php vendor/bin/sami.php update gen-docs.php
. The documentation will be generated in a folder called 'docs'.
Examples of common tasks
e.g.
- How to make curl requests while authenticated via oauth.
- How to monitor background jobs.
- How to run the app through a proxy.
- Internal git workflow
- Pull request guidelines
- Tracker project
- irc channel
- Please open issues on the repo tracker for any incorrect behaviour, or better yet, make a pull request with a failing test case 😄
This project is licensed under the MIT License.