#laravel collection filter example
Explore tagged Tumblr posts
laravelvuejs · 5 years ago
Photo
Tumblr media
chunk | Laravel Collections In this episode we are tackling, the method chunk(). For the best experience, follow along in our interactive school at About This ... source
0 notes
craigbrownphd-blog-blog · 5 years ago
Text
What’s going on on PyPI
Scanning all new published packages on PyPI I know that the quality is often quite bad. I try to filter out the worst ones and list here the ones which might be worth a look, being followed or inspire you in some way. • h-anomaly A small example package Anomaly detection using hierarchical clustering, anomaly detector, classifiers and fast model rebuilding • keras-complex Complex values in Keras – Deep learning for humans. (https://…/Convolution#Domain_of_definition ) could provide some interesting results in signal processing-based deep learning. A simple(-ish) idea is including explicit phase information of time series in neural networks. This code enables complex-valued convolution in convolutional neural networks in (https://keras.io ) with the (https://tensorflow.org ) backend. This makes the network modular and interoperable with standard keras layers and operations. • konduit konduit: Enterprise Runtime for Machine Learning Models • pylana Python API for LANA Process Mining • waymo-od-tf2-0 Waymo Open Dataset libraries. • whynotr Companion package to whynot: A collection of causal estimators in R. • agnes AGNES – Flexible Reinforcement Learning Framework with PyTorch • Chamak A python implementation of laravel framework for machine learning, AI, datascience and data intensive work. • drepr Data Representation Language for Reading Heterogeneous Datasets. This library allows reading heterogeneous datasets of different formats and layouts. For more information, please visit (https://…/d-repr ). • onpoint NLP question answering service http://bit.ly/39m8utf
0 notes
craigbrownphd · 5 years ago
Text
What’s going on on PyPI
Scanning all new published packages on PyPI I know that the quality is often quite bad. I try to filter out the worst ones and list here the ones which might be worth a look, being followed or inspire you in some way. • h-anomaly A small example package Anomaly detection using hierarchical clustering, anomaly detector, classifiers and fast model rebuilding • keras-complex Complex values in Keras – Deep learning for humans. (https://…/Convolution#Domain_of_definition ) could provide some interesting results in signal processing-based deep learning. A simple(-ish) idea is including explicit phase information of time series in neural networks. This code enables complex-valued convolution in convolutional neural networks in (https://keras.io ) with the (https://tensorflow.org ) backend. This makes the network modular and interoperable with standard keras layers and operations. • konduit konduit: Enterprise Runtime for Machine Learning Models • pylana Python API for LANA Process Mining • waymo-od-tf2-0 Waymo Open Dataset libraries. • whynotr Companion package to whynot: A collection of causal estimators in R. • agnes AGNES – Flexible Reinforcement Learning Framework with PyTorch • Chamak A python implementation of laravel framework for machine learning, AI, datascience and data intensive work. • drepr Data Representation Language for Reading Heterogeneous Datasets. This library allows reading heterogeneous datasets of different formats and layouts. For more information, please visit (https://…/d-repr ). • onpoint NLP question answering service http://bit.ly/3a1Bmrn
0 notes
geoclassified · 6 years ago
Text
PHP Classifieds Script Free Download
Tumblr media
Nimble Classified Ads Script – PHP And Laravel Geo Classified Advertisement CMS is made to engage you to manufacture a 100% responsive and explicit assembled site subject to a most recent variety of the most standard PHP system Laravel. Are you too an extraordinary degree searching forward for an unfathomable depicted headways cms structure? The most progression Nimble Classified Ads Script – PHP And Laravel Geo Classified Advertisement CMS will meet your necessities. It's one of the must purchase progressions substance which you can't keep up a vital separation from If you require a part rich substance that has everything and combines in excess of 50 highlights which you have to build up a captivating amassed business center site. Regardless of what you look like at it stunning looking gathering, Nimble organized headways content is particularly orchestrated and made by keeping in view the prerequisites and necessities everything considered. Deft Classified Ads Script – PHP And Laravel Geo Classified Advertisement CMS has particularly present day, striking and eye getting outline which impacts it to ascend at the web and is a victor amongest the most magnificent gathered substance open at code pig out. It's a great looking structure and present-day course of action will make you went gaga for it. 100% working and emerge course of action is attempted and genuine, easy to use, not simply that its association and setup will help give your classifieds regions and it's postings have a competent appearance. With Nimble Classified Ads Script – PHP And Laravel Geo Classified Advertisement CMS you can make your classifieds headways national, worldwide or notwithstanding for some predefined for several nations.
Key Features:
Creative And Powerful Admin Panel.
Multi-Languages.
Live Commenting System In Ads Through Facebook.
Asked for Ad Verification Through Mobile Notification (Twilio SMS Gateway Integrated).
Clients Rating System – Registered Users Can now leave responses/surveys.
Google Map Listings (Worldwide classifieds can be seen through guide).
Custom Pages Builder (extraordinarily competent custom page producer choice).
Multi Skins – Easy Customization Options.
100% Mobile Responsive &Retina Ready.
First Time Ever Most Unique Feature: Category and Sub Category Management. 
Accumulated headway posting by techniques for adaptable insistence.
Stripe Payment Gateway To Charge Your Customers.
Post Ad With Multiple Images.
The course of action Wise Ads Listing.
Direct.
Custom Fields Add-On.
Most valued Ads.
Premium Ads System (+Google Ad-sense).
Worked with PHP/MySQL/HTML 5/CSS 3.
Structures: Laravel, Bootstrap, Query.
Introduction page customization: (head can change shades and request modify all segments from the dashboard).
CMS for static pages (make pages like, about us, faq, terms approach, and so on).
Front end posting accommodation.
Effortlessly establishment and orchestrated to use in only 2 minutes.
Genuine Tracking System.
Examination.
Email Verification System.
Site enhancement Friendly and SEO Ready.
Login Via Email Address.
Online frameworks organization Sharing Options.
Advertisements Upgrade System.
Record Notifications.
Email Notifications.
Spam Controlling.
Dynamic Chat System.
Confided in Seller Badge.
Intrigue Filter.
Included Ads.
Advanced Messaging System.
Simple To Install.
Simple To Update.
Sitemap.
Upkeep Mode.
Free Lifetime Updates And Anytime Access To Our Help And Support Portal.
Clean Programming and source code, gainful, especially recorded Pages System.
Contact Form.
Confided in Seller Badge.
Advance Profile Verification System.
Record Upgrade.
Spam Control System.
Before making utilization of the development depicted to check for occupations you should isolate your activity require. You should check for such occupations that suit best of your capacities. Showing your own abilities fittingly can lead you to investigate through the development banks satisfactorily. Evaluation of your abilities close to your interests winds up being generally central. You in like way should consider your blocks. There might be occupations which are preposterously requesting, yet likely won't work for you. Thusly understanding your own potential results appropriately can make your journey to work a success.
There are such a basic number of affiliations offering on the web work classifieds and keeping up business banks that it winds up being troublesome for any person to go for the best one. Actually, even there are making occasions of affiliations faking with the activity classifieds. Starting here of view Freelance the load up bank can be insinuated for instance beyond any doubt as an alliance that has met any activity searcher's hankering with a beast, especially directed business bank in past and besides for a noteworthy timeframe to come.
The two directors who post vocations and occupation searchers who inspect for occupations can be normally profited by an online development portrayed in the running with ways:
Business classifieds when in doubt keep up a monster database of occupation postings. The term work banks should be shown here in perspective of its trademark similarity of having assets at any single place like any bank. Occupations are everything viewed as recorded in a managed way. You can discover occupations as appeared by your subject from your favoured gathering. The receptiveness of copious assets regardless of what you look like at it put beneficially keeps online business classifieds much before different techniques for occupation headways.
Demand is another fundamental bit of amassed work. Since the activity agile classifieds have a colossal database of employment to manage, the occupations are thusly amassed by explicit portrayals. An occupation dispersion can post in this activity bank any activity that organizes the most realistic portrayal. In the interim work, a searcher can stay to check for the pined for activity by essentially having a speedy take a gander at the classes consequently promising the demand.
Ads Classified Scripts locales can be additionally extended by building associations with key organizations that have a similar specialty of intrigue. In the Auto precedent, neighbourhood organizations, for example, car parts and frill stores, accident coverage providers and vehicle washing offices can be drawn nearer and offered free promoting space on the site. Not exclusively will such organizations be pulled in to your client base, yet their advertisements will likewise produce site action from their client base.
An objective region or regions should then be chosen for the ordered promotion site as a larger part of things regularly recorded on such destinations either can't be transported abroad or it is amazingly hard to do as such. Pet supplies might be effortlessly transported to removed purchasers, yet pets, firearms and autos move best in neighbourhood markets.
In an online activity organized, both an occupation advertisement spot and an occupation searcher can keep up a profile by basically enrolling and finishing the techniques. At whatever point an occupation fits the ability or fairly propensity of any activity searcher Free Web script, he/she gets educated all things considered updating the mission for work further.
By a long shot, most don't regard the intensity of cautiously made collected progressions. They think collected advancements are for offering vehicles, or discovering occupations, and not for growing a business. While it's genuine an arranged progression is an OK strategy to accomplish the recently referenced, it is correspondingly obvious that assembled advancements can be utilized to dispatch and extend multi million-pound affiliations.
Different affiliations depend only on this inconsequential effort notification to convey a liberal extent of their yearly turn over. The reason is the principal. When you have found how to outfit the power of these depicted headways, you truly won't have to run costly show advancements utilizing all methods.
Note that the key point about masterminded advancements is that they are best when utilized as lead generators, and not to offer from. In these headways, you are not attempting to impact somebody to encounter cash with you. You are attempting to perceive a potential client by having that client interface with you because of the business. Exactly when potential clients have isolated themselves, you would then have the ability to get up to speed with your standard postal mail offer for the thing or association you are advancing.
Making a persuading assembled headway is a boss amongest the most asking for sorts of copy creation. In twenty words or less, you need to catch the client's eye and engage them enough to activate them into calling you for more data. You can't depend upon eye getting charts or ace plans to get the looks at the thought.
0 notes
mbaljeetsingh · 8 years ago
Text
Measure Anything in Laravel with StatsD
Laravel Tutorials / September 25, 2017
Measure Anything in Laravel with StatsD
I want to show you some tools and techniques you can use to measure anything and everything that you want in your Laravel applications with StatsD. These ideas are simple and not new; yet, I believe that the simplicity and power are what makes StatsD great.
You can also take the ideas in this article and apply them to any programming language or stack. Instrumenting your code can have a huge payoff as your application scales and can help you gain deep insights.
Most importantly, adding new instrumentation to your application should be as painless as possible for developers. Any friction in the collecting and reporting of new insights means developers won’t use it. I think a good measurement of “frictionless” is for a developer to start collecting on any metric in production in thirty minutes or less.
Enter StatsD:
A network daemon that runs on the Node.js platform and listens for statistics, like counters and timers, sent over UDP or TCP and sends aggregates to one or more pluggable backend services (e.g., Graphite).
StatsD is a simple, easy way to start collecting metrics quickly and displaying them in a graphing program. The great thing about StatsD is that the calls happen over UDP, which is fast, and a “fire-and-forget” transaction. Also, the code in development won’t be affected if you’re not running StatsD.
Why You Should Instrument Your Code
In the context of web applications and services, instrumentation can be grouped into three critical areas: network, server, and application. We will be focused on application instrumentation, or to put it another way, measuring metrics in your code, such as timing, gauges, and increments.
You can measure everything from how many logins you’re application has seen in the last hour, to how quickly a model method runs a database query on average. Another example might be measuring the average time a controller method takes to run. The possibilities are endless!
Instrumentation is an addicting habit you can use to build intelligence which can help you make decisions and respond to issues backed by data. Measuring performance can prove or debunk theories you have about your code using insights that only production can provide.
I believe that application-level instrumentation is probably the most complicated tier, but the payoff can be huge to the health and growth of your applications. If you’re not using instrumentation in your code yet, you probably don’t have a good idea of how your application performs at scale.
Let’s change that and see how quickly you can start incorporating StatsD into your application stack. I am not going to minimize the fact that you’ll need some support in running and maintaining StatsD and Graphite in production, but setting it up on Digital Ocean isn’t too hard. We will just use a local Docker container to make things easy for you so you can focus on experimenting.
Getting Started
The beautiful thing about the Graphite Docker container is that Graphite and StatsD are self-contained and you can get them running in one command.
From the Graphite Installation Guide you can run the following Docker command (I’ve modified the port to 8100 since port 80 is in use on my machine):
docker run -d\ --name graphite\ -p 8100:80\ -p 2003-2004:2003-2004\ -p 2023-2024:2023-2024\ -p 8125:8125/udp\ -p 8126:8126\ graphiteapp/graphite-statsd 37f5884a063f2e3df1e13377e7221e0aff7f5f7079b16b38ff764f3490c95d57
If you go to http://localhost:8100, you should see the Graphite interface! We are ready to send calls to StatsD through a laravel app and start visualizing metrics with Graphite.
Next, we need to install Laravel 5.5, and we are going to use the league/statsd package to send metrics to StatsD over UDP:
$ laravel new laravel-statsd $ cd laravel-statsd $ composer require league/statsd
At the time of this writing, the League StatsD package doesn’t configure package auto-discovery (I have submitted a PR for it ;), so you need to manually set the service provider and facade:
// Provider 'providers' => [ // ... League\StatsD\Laravel5\Provider\StatsdServiceProvider::class, ], // Facade 'aliases' => [ // ... 'Statsd' => League\StatsD\Laravel5\Facade\StatsdFacade::class, ]
Next, publish the configuration for the StatsdServiceProvider:
php artisan vendor:publish --provider="League\StatsD\Laravel5\Provider\StatsdServiceProvider"
You will not need to update the config/statsd.php file with the Docker container we are running, but having this configuration on hand will be useful when you run StatsD in production.
To verify the installation is working, make sure you can resolve the StatsD client via Laravel’s service container:
$ php artisan tinker >>> app('League\StatsD\Client'); => League\StatsD\Client {#713} >>> app('statsd'); => League\StatsD\Client {#719}
A Simple API Counter
The simplest thing you can track with StatsD is probably a counter. You can call both increment and decrement:
# Using the Facade Statsd::increment('pageviews'); Statsd::decrement('some.metric'); # Custom delta and sample rate of 10% Statsd::increment('my.sample', 5, 0.1);
The first example will increment the “pageviews” counter by one. The Statsd::decrement() method works the same way, but decrements the count.
Although you would typically track page views in your application with Google Analytics, let’s say that you wanted to monitor how many requests your API routes receive. Monitoring your API requests/second could be super valuable, a good indicator of the health of your application, and you would start to see some trends.
In the simplest form, we could build a middleware for this purpose. Let’s try it out!
First, create the middleware:
$ php artisan make:middleware RequestCounter
Next, let’s define the middleware with a parameter defining what type of request is being counted:
<?php namespace App\Http\Middleware; use Closure; class RequestCounter { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $type) { \Statsd::increment("requests.{$type}"); return $next($request); } }
We use the Statsd facade to increment the requests.$type counter. Using dots (.) separates the value into folders in the Graphite interface. For example, requests.api would make a folder requests/api/ as you will see in a moment.
Next, let’s add this middleware to the App\Http\Kernel.php file in both the web and API groups:
protected $middlewareGroups = [ 'web' => [ 'counter:web', // ... ], 'api' => [ 'counter:api', 'throttle:60,1', 'bindings', ], ]; protected $routeMiddleware = [ // ... 'counter' => \App\Http\Middleware\RequestCounter::class, ];
Now our routes will get counted with every request! We are ready to start working with Graphite and visualizing our metrics being tracked through this middleware.
The first thing we are going to use in Graphite is the dashboard. Visit http://localhost:8100/dashboard. Click “Relative Time Range” and pick “Show the past 1 minutes” and click “OK.” Enable Auto-Refresh and make it refresh every 5 seconds. It should look something like the following:
The dashboard UI allows you to filter by metric and build out dashboards that auto-update that you can use to monitor things in real-time.
We haven’t collected any data yet, so we need to define a route and run some HTTP requests to trigger our middleware.
Let’s set a test web route in routes/web.php:
// routes/web.php Route::get('test', function () { return 'OK'; });
To simulate traffic, use seige or Apache Benchmark. Siege is show, but ab would be similar:
$ brew install siege $ siege -t 60s -c 20 http://ift.tt/2wPwaaG
We run Siege for 60 seconds with 20 concurrent users. While Siege is running, jump back over to the graphite UI and enter (or pick at the top) “stats.requests.”. It should start looking like this:
And you’ve just written your first custom StatsD counter! Are you hooked yet?
Monitoring Controllers
Let’s say that you want to track how long it takes for a controller action to run. If you overload the Illuminate\Routing\Controller::callAction() method, you can track the rough time it takes to call a controller action. We could use an after middleware, but the callAction technique means we aren’t timing any middleware, just the controller action.
Open up the App\Http\Controllers\Controller class and add the following method:
/** * @inheritdoc */ public function callAction($method, $parameters) { // Remove App\Http\Controller // Split remaining namespace into folders $className = str_replace('\\', '.', get_class($this)); $timerName = sprintf('controller.%s.%s', $className, $method); $timer = \Statsd::startTiming($timerName); $response = parent::callAction($method, $parameters); $timer->endTiming($timerName); return $response; }
This method is getting the controller class name and replacing the backslash characters with dots. After starting the timer with our metric name, we call the parent and then end the timer, giving us the time the controller action took in milliseconds.
The dots will create separate folders for each part of the namespace, so your controller metrics for each action will be organized cleanly in Graphite. You can also combine them in interesting ways.
To try out our controller timer, the next thing we need to do is create a controller and define a route:
$ php artisan make:controller TestController
Effectively, the timer stats would be located at “stats.timers.controller.App.Http.Controllers.TestController.Index” given our controller namespace.
Here’s the @index method, which is arbitrary:
<?php namespace App\Http\Controllers; class TestController extends Controller { public function index() { return 'OK'; } }
Next, replace (or comment out the other route) with the following in the routes/web.php:
Route::get('test', 'TestController@index');
Make siege on your application again, and you should start getting timer stats on the TestController:
siege -t 60s -c 20 http://ift.tt/2wPwaaG
While running siege you can watch the real-time stats piling up by updating your dashboard filter. The dashboard UI allows you to add multiple graphs and save them for later use (or to display on a flatscreen TV to look legit).
Here’s what the folder structure ends up looking like in Graphite:
Timers give you various stats including percentiles, average (mean), standard deviation, sum, lower and upper bounds.
Learn More
Well, that’s it for our whirlwind tour of using StatsD with Laravel. If you’ve never instrumented code, I hope that you practice and hopefully one day get something out into production!
I find that StatsD is invaluable in working with legacy systems so learning how to instrument your code has great returns for your investment.
I recommend that you get familiar with the different metric types that StatsD supports (Gauges and Sets are cool).
As far as reading up on the instrumenting of code, I highly recommend that you read Measure Anything, Measure Everyting, the original Etsy blog post introducing StatsD. Also, Counting & Timing on the Flickr blog was an even earlier description and implementation of the ideas behind StatsD.
via Laravel News http://ift.tt/2wRuUiB
0 notes
laravelvuejs · 6 years ago
Text
tap | Laravel Collections - Laravel
tap | Laravel Collections – Laravel
tap | Laravel Collections – Laravel
[ad_1]
In this episode we are tackling the tap method.
For the best experience, follow along in our interactive school at https://www.coderstape.com
About This Course
In this series, we take a look at each of the available methods in the Laravel Collection class and dive deep through examples in explaining what it does.
[ad_2] laravel “laravel collection filter…
View On WordPress
0 notes
laravelvuejs · 6 years ago
Text
count | Laravel Collections - Laravel
count | Laravel Collections – Laravel
count | Laravel Collections – Laravel
[ad_1]
In this episode we are tackling, the method count().
For the best experience, follow along in our interactive school at https://www.coderstape.com
About This Course
In this series, we take a look at each of the available methods in the Laravel Collection class and dive deep through examples in explaining what it does.
[ad_2] laravel “laravel collection…
View On WordPress
0 notes
mbaljeetsingh · 8 years ago
Text
Bring Laravel Collections to JavaScript with Collect.js
Laravel Packages / June 17, 2017
Bring Laravel Collections to JavaScript with Collect.js
Collect.js is a port of Laravel Collections to JavaScript. It’s dependency free and makes working with arrays and objects easy.
Here is an example of utilizing the where method:
const collection = collect([ {'product': 'Desk', 'price': 200}, {'product': 'Chair', 'price': 100}, {'product': 'Bookcase', 'price': 150}, {'product': 'Door', 'price': '100'}, ]); const filtered = collection.where('price', 100); filtered.all(); //=> [ //=> {'product': 'Chair', 'price': 100}, //=> {'product': 'Door', 'price': '100'} //=> ]
As you can see, it’s almost a one to one map with the Laravel version and it even includes the fairly new Collection Tap method but it does have some differences when dealing with comparisons:
All comparisons in collect.js are done using strict equality. Using loose equality comparisons are generally frowned upon in JavaScript. Laravel only performs “loose” comparisons by default and offer several “strict” comparison methods. These methods have not been implemented in collect.js because all methods are strict by default.
You can install Collect.js through NPM.
npm install collect.js
For complete documentation and installation take a look at the GitHub repo or the NPM page.
via Laravel News http://ift.tt/2rqHraK
0 notes
mbaljeetsingh · 8 years ago
Text
Laravel Collection “tap” Method
Laravel 5.4.10 introduces a new tap method on collections which allow you to “tap” into the collection at a specific point and do something with the results while not affecting the main collection.
This feature is best described through examples and let’s pretend you have the following array:
$items = [ ['name' => 'David Charleston', 'member' => 1, 'active' => 1], ['name' => 'Blain Charleston', 'member' => 0, 'active' => 0], ['name' => 'Megan Tarash', 'member' => 1, 'active' => 1], ['name' => 'Jonathan Phaedrus', 'member' => 1, 'active' => 1], ['name' => 'Paul Jackson', 'member' => 0, 'active' => 1] ];
Now we convert this into a collection, filter the data, and tap into it at two different points:
return collect($items) ->where('active', 1) ->tap(function($collection){ return var_dump($collection->pluck('name')); }) ->where('member', 1) ->tap(function($collection){ return var_dump($collection->pluck('name')); });
Once this runs it’ll output the following the following for the first tap:
David Charleston, Megan Tarash, Jonathan Phaedrus, Paul Jackson
Then the second:
David Charleston, Megan Tarash, Jonathan Phaedrus
Tap versus Pipe
Laravel also provides another similar method to tap named pipe and they are similar in that they can be performed inside a collection pipeline. However, they have two primary differences:
Tap allows you to do something with the data available but it does not modify the original. Pipe modifies the results in the collection based on its return value. For instance:
return collect($items) ->where('active', 1) ->pipe(function ($collection) { return $collection->push(['name' => 'John Doe']); }); // David Charleston, Megan Tarash, Jonathan Phaedrus, Paul Jackson, John Doe
via Laravel News http://ift.tt/2lbwhX3
0 notes
mbaljeetsingh · 8 years ago
Text
20 Awesome PHP Libraries For Early 2017
This week we have for you a collection of high-quality PHP libraries that have caught our eye in the last couple of months. We’ve tried our best to include projects that are active, well documented, and will have a realistic shot at finding a place in your developer’s workbelt.
If we’ve haven’t included your favorite new library, feel free to share it in the comments :)
Requests for PHP
A no-dependencies library that lets you send HTTP requests. It provides the needed methods for adding headers, accessing response data, handling forms, and everything else you may need, neatly packaged in a clean and easy to use API.
$headers = array('Accept' => 'application/json'); $options = array('auth' => array('user', 'pass')); $request = Requests::get('http://ift.tt/ULh0JY', $headers, $options); var_dump($request->status_code); // int(200) var_dump($request->headers['content-type']); // string(31) "application/json; charset=utf-8" var_dump($request->body); // string(26891) "[...]"
Rinvex Country
Rinvex Country is a PHP package that lets developers retrieve detailed information about the countries of the world. Using the over 50 methods you can get the area of Angola, the currency of Cyprus, the native name of Namibia or even the FIFA name of Finland. There is a ton of info available and the data sources are pretty reliable.
$egypt = country('eg'); $egypt->getCapital(); // Cairo $egypt->getDemonym(); // Egyptian $egypt->getTld(); // .eg $egypt->getContinent(); // Africa $egypt->getSubregion(); // Northern Africa $egypt->getBorders(); // ["ISR","LBY","SDN"]
Botman
A PHP library for developing messenger bots. Works with most of the popular messaging platforms including Facebook Messenger, Slack, Telegram, WeChat, and others. There is also a helpful boilerplate Laravel project available here.
// create an instance $botman = BotManFactory::create($config); // give the bot something to listen for. $botman->hears('hello', function (BotMan $bot) { $bot->reply('Hello yourself.'); }); // start listening $botman->listen();
If you are not familiar with the concept of messenger bots we suggest you check out our article Developer’s Introduction To Chatbots.
Charts
Laravel package for generating highly customizable charts out of datasets. The package works as a PHP wrapper for multiple built-in JavaScript chart libraries, allowing devs to create a wide variety of graphs, gauges and progressbars using only one tool.
$chart = Charts::create('line', 'highcharts') ->view('custom.line.chart.view') ->title('My nice chart') ->labels(['First', 'Second', 'Third']) ->values([5,10,20]) ->dimensions(1000,500) ->responsive(false);
Swap
Swap allows you to retrieve currency exchange rates from a number of services such as Fixer, Google, and Yahoo. Request responses can be easily cached and accessed later. The library is available in the form of a Laravel Package as well.
// Build Swap with Fixer.io $swap = (new Builder()) ->add('fixer') ->build(); // Get the latest EUR/USD rate $rate = $swap->latest('EUR/USD'); // 1.129 $rate->getValue(); // Get the EUR/USD rate 15 days ago $rate = $swap->historical('EUR/USD', (new \DateTime())->modify('-15 days'));
Math PHP
A collection of mathematical functions and algorithms ranging from simple algebra to finances, statistics, numerical analysis and others fields. The library is modular, has a straightforward API, and doesn’t require any external dependencies.
// Factors of an integer $factors = Algebra::factors($n); // Fibonacci sequence $fib = Advanced::fibonacci($n); // Combinations $nCk = Combinatorics::combinations($n, $k); // Likelihood ratios $LL = Experiment::likelihoodRatio($a, $b, $c, $d);
PHPUnit
PHPUnit is an advanced testing framework that enables teams to thoroughly test their code. Unit tests are written in standalone object-oriented classes with the help of many methods for handling assertions, dependencies, etc. A simple CLI is provided for running test and generating reports.
class StackTest extends TestCase { public function testPushAndPop() { $stack = []; $this->assertEquals(0, count($stack)); array_push($stack, 'foo'); $this->assertEquals('foo', $stack[count($stack)-1]); $this->assertEquals(1, count($stack)); $this->assertEquals('foo', array_pop($stack)); $this->assertEquals(0, count($stack)); } }
Atoum
A less popular testing framework we also wanted to share. Atoum offers a one-step installation precess and a relatively simple workflow, while still maintaining a ton of great features. It has a mock engine, expressive assertions, and a CLI that can execute multiple tests in parallel.
$this->given($testedInstance = new testedClass()) ->and($testedClass[] = $firstValue = uniqid()) ->then ->sizeof($testedInstance)->isEqualTo(1) ->string($testedClass[0])->isEqualTo($firstValue);
Simple Regex Language
A PHP implementation of the Simple Regex Language – a verbose way of writing regular expressions. The library provides multiple methods that can be chained together, forming readable and easy to understand RegEx rules. The library has ports for JavaScript and Python as well.
$query = SRL::startsWith() ->anyOf(function (Builder $query) { $query->digit() ->letter() ->oneOf('._%+-'); })->onceOrMore() ->literally('@') ->anyOf(function (Builder $query) { $query->digit() ->letter() ->oneOf('.-'); })->onceOrMore() ->literally('.') ->letter()->atLeast(2) ->mustEnd()->caseInsensitive();
Stash
Stash makes it easy to speed up your code by caching the results of expensive functions or code. Certain actions, like database queries or calls to external APIs, take a lot of time to run but tend to have the same results over short periods of time. This makes it much more efficient to store the results and call them back up later.
$pool = $this->cachePool; // Get a Stash object from the cache pool. $item = $pool->getItem("/user/{$userId}/info"); // Get the data from it, if any happens to be there. $userInfo = $item->get(); // Check to see if the cache missed, which could mean that it either // didn't exist or was stale. if($item->isMiss()) { // Run the relatively expensive code. $userInfo = loadUserInfoFromDatabase($userId); // Set the new value in $item. $item->set($userInfo); // Store the expensive code so the next time it doesn't miss. $pool->save($item) }
PHP VCR
A port of the popular Ruby library for testing HTTP interactions. PHP VCR records HTTP requests and stores them in “cassettes” which can be replayed later on. A set of testing utilities are also provided, making it possible to inspect and compare recordings in detail.
// After turning on, the VCR will intercept all requests \VCR\VCR::turnOn(); // Record requests and responses in cassette file 'example' \VCR\VCR::insertCassette('example'); // Following request will be recorded once and replayed in future test runs $result = file_get_contents('http://example.com'); $this->assertNotEmpty($result); // To stop recording requests, eject the cassette \VCR\VCR::eject(); // Turn off VCR to stop intercepting requests \VCR\VCR::turnOff();
OAuth 2.0 Server
This library allows you to easily configure an OAuth 2.0 server and set up all the authentication levels needed to protect your API. It is fully standards compliant and supports all the grants defined by OAuth protocol. The Laravel Passport module is built on top of the OAuth 2.0 Server.
// Setup the authorization server $server = new \League\OAuth2\Server\AuthorizationServer( $clientRepository, $accessTokenRepository, $scopeRepository, $privateKey, $publicKey ); // Enable a grant on the server $server->enableGrantType( new \League\OAuth2\Server\Grant\ClientCredentialsGrant(), new \DateInterval('PT1H') // access tokens will expire after 1 hour );
Imagine
An image manipulation library that tries to bring together all low level PHP image processing libraries under the same object-oriented API. This allows Imagine to be used for a wide variety of tasks such as drawing, resizing, cropping, filters, effects, metadata editing, and others.
$palette = new Imagine\Image\Palette\RGB(); $image = $imagine->create(new Box(400, 300), $palette->color('#000')); $image->draw() ->ellipse(new Point(200, 150), new Box(300, 225), $image->palette()->color('fff')); $image->save('/path/to/ellipse.png');
MINI
Extremely simple and easy to understand skeleton PHP application, providing only the most essential features every project needs. It does not strive to be a do-it-all framework like Laravel, but due to it’s simplicity MINI can be used for getting smaller apps up and running in no time.
// Working with the model $songs = $this->model->getAllSongs(); $amount_of_songs = $this->model->getAmountOfSongs(); // Loading views require APP . 'views/_templates/header.php'; require APP . 'views/songs/index.php'; require APP . 'views/_templates/footer.php';
AWS SDK
The official PHP library for working with Amazon Web Services. The SDK makes it easy to connect AWS with any PHP project and access all the various available services. There is also a useful Laravel wrapper which can be found here.
// Instantiate an Amazon S3 client. $s3 = new S3Client([ 'version' => 'latest', 'region' => 'us-west-2' ]); $s3->putObject([ 'Bucket' => 'my-bucket', 'Key' => 'my-object', 'Body' => fopen('/path/to/file', 'r'), 'ACL' => 'public-read', ]);
Purl
Lightweight PHP library for working with URLs. With Purl you can compose complex paths attribute by attribute, extract data from URLs, manipulate queries, recognize URLs in strings, and much more.
$url = \Purl\Url::parse('http://jwage.com') ->set('scheme', 'https') ->set('port', '443') ->set('user', 'jwage') ->set('pass', 'password') ->set('path', 'about/me') ->set('query', 'param1=value1&param2=value2'); echo $url->getUrl(); // http://ift.tt/2jKXmzm echo $url->publicSuffix; // com echo $url->registerableDomain; // jwage.com
Daux.io
Documentation generator that uses a simple folder structure and Markdown files to create responsive documentation websites. Daux.io has automatic syntax highlighting, 4 theming options, Bootstrap HTML for easy customization, navigation with readable URLs, and many other goodies.
// Example configuration { "title": "DAUX.IO", "tagline": "The Easiest Way To Document Your Project", "author": "Justin Walsh", "image": "app.png", "html": { "theme": "daux-blue", "breadcrumbs": true, "repo": "justinwalsh/daux.io", "edit_on_github": "justinwalsh/http://ift.tt/2jvDRHq;, "twitter": ["justin_walsh", "todaymade"], "google_analytics": "UA-12653604-10", "links": { "Download": "http://ift.tt/2kjtzyi;, "GitHub Repo": "http://ift.tt/2jvsvmX;, "Made by Todaymade": "http://ift.tt/2kjH0OT; } } }
Dompdf
Dompdf is a PDF generator that takes regular HTML markup and converts it to .pdf files. It understands most CSS rules, which can be fed in-line or via an external stylesheet.
// reference the Dompdf namespace use Dompdf\Dompdf; // instantiate and use the dompdf class $dompdf = new Dompdf(); $dompdf->loadHtml('hello world'); // (Optional) Setup the paper size and orientation $dompdf->setPaper('A4', 'landscape'); // Render the HTML as PDF $dompdf->render(); // Output the generated PDF to Browser $dompdf->stream();
Instaphp
Non-official library for accessing the Instagram API. It provides developers with an easy way to authenticate their app and get access to various Instagram data endpoints including images, users, likes, comments, and tags.
$api = new Instaphp\Instaphp([ 'client_id' => 'your client id', 'client_secret' => 'your client secret', 'redirect_uri' => 'http://ift.tt/2jNPWIY', 'scope' => 'comments+likes' ]); $popular = $api->Media->Popular(['count' => 10]); if (empty($popular->error)) { foreach ($popular->data as $item) { printf('<img src="%s">', $item['images']['low_resolution']['url']); } }
Latitude
Zero-dependencies library for building SQL queries using chainable methods. It supports most query types and works well with MySQL, Postgres, SQL Server, and other databases. There are also built-in escaping helpers for protecting against SQL injection.
$select = SelectQuery::make( 'id', 'username' ) ->from('users'); echo $select->sql(); // SELECT id, username FROM users
via Tutorialzine http://ift.tt/2jL2PX1
0 notes