How to hide the "Last Login" line on the terminal
One of the first things I do after a fresh setup. That annoyed me for the /longest/ time. pic.twitter.com/j9LvzbMQQd
— Jaggy ? (@jaggygauran) August 31, 2017
Read more [twitter.com]
One of the first things I do after a fresh setup. That annoyed me for the /longest/ time. pic.twitter.com/j9LvzbMQQd
— Jaggy ? (@jaggygauran) August 31, 2017
Read more [twitter.com]
On the Tighten co blog Caleb Porzio wrote a small post on how you can boot your model traits. It's a very handy feature that's being used a quite a few Spatie packages.
TL;DR Use bootNameOfTrait() instead of boot() in a model trait to avoid being overwritten by the base model’s boot() method.
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
I ❤️ Laravel's tinker command and use it everyday. Caleb Porzio, an engineer at Tighten Co, wrote a good post on the that command, containing lots of cool stuff I didn't knew tinker could do.
Although some of the value Tinker provides is clear at first glance, it also has loads of hidden and exciting features available out-of-the-box. Let’s walk through and take a look at some ways you can super-charge your Tinker workflow.
https://blog.tighten.co/supercharge-your-laravel-tinker-workflow
Nikush Patel created an awesome little site where he shares PHPStorm tips. Every tip is demonstrated by an animated gif.
I'm a big fan of PhpStorm and an equally big fan of keyboard shortcuts and optimised workflows, so I wanted to share all the best tips and tricks I know to help everyone else make the most of PhpStorm as well!I produce useful tips in bite-sized gif recordings so they are easier to consume than reading the docs.
Miklós Galicz posted a short article on how he managed to override Laravel's str_slug helper function.
Long story short, until this is resolved one way or another... A really obscure but powerful tool can be a temporary solution for this. It's called Helper Overloading. Laravel's helpers are created in a way that checks if the method already exists. ... This is really great, the only thing remaining is to actually add our own method before Laravel creates it own version.
https://blackfyre.ninja/blog/fixing-slug-generation-problems
Emil Ong shares some cool ways you can leverage ES6.
Here are a few ES6 techniques that aren’t really tricks, just exploiting some of the new syntax either to reduce code, improve readability, or possibly just have fun. I’m planning on collecting more here, so please feel free to bookmark and check back every once in a while.
Gary Hockin is a developer advocate at JetBrains, the firm that created PhpStorm. In this Nomad PHP video Gary shares some of his favourite PhpStorm secrets.
Joe Ferguson shares a tip on how to make a version of PHPUnit's assertArraySubset where the order of the array does not matter.
The problem with this test is that `assertArraySubset()` will fail if the items in the array are out of order. And since we don’t have an `ORDER BY` on our query in our data source we cannot guarantee the order of the returned data.
Matt Stauffer has been working on a book titled "Laravel: Up and Running" which will be released soon. In a post on his blog Matt shares a few hidden Laravel gems that he discovered while writing his book.
No blog post could contain all of the new things I learned from writing this book. I've been using—and teaching about—Laravel for years, and I was still shocked by how many tools and helpers and features I discovered.Here are a few that stand out to me that I had never seen prior to writing the book.
https://mattstauffer.co/blog/things-i-didnt-know-laravel-could-do
Composer really needs no introduction. At this point the PHP community pulled in billions of packages. Here are some Composer options that are not so well known.
You can view the versions of all the packages in your project by running composer show -i. Let's try it out in our Blender Laravel template:
Want to see all the dependencies of the installed packages in a tree? Then run composer show -t:
If you need help using a specific package then you can open it's documentation in a browser using composer. Try running composer home spatie/laravel-fractal to see it in action.
Know some other nice Composer tricks? Let me know in the comments below.
Homestead is a pre-packaged Vagrant box that includes a good development environment. It was made and is maintained by Taylor Otwell, the creator of Laravel. In this post I'd like to share some tips regarding this box.
folders:
- map: ~/dev/sites
to: /home/vagrant/sites
192.168.10.10 url-to-your-homested-project.com #default ip of the homestead box
You can avoid having to edit the hosts file by using a xip.io-url. Xip.io is a special domain created by Basecamp. The nameserver of that domain will resolve all urls to the ip-address that is specified inside the url. For example: "myproject.192.168.10.10.xip.io" will resolve to 192.168.10.10. If you use such an url in your homestead configuration there's no need to edit your hosts file.
sites
- map: spatie.192.168.10.10.xip.io #no need to put this url in your hosts file
to: /home/vagrant/sites/spatie.be/public
The downside of using a xip.io-url is that such url's are quite long. This can be improved by installing a local dns server. The local dns server will resolve all lookups of a given top level domain to the ip address of the homestead box. Here's a nice article that explains how to resolve all *.dev requests to a specified ip adress.
On OSX these steps can be used to install and configure dnsmasq to point all *.dev requests to homestead.
# Install dnsmasq
brew install dnsmasq
# Copy the default configuration file.
cp $(brew list dnsmasq | grep /dnsmasq.conf.example$) /usr/local/etc/dnsmasq.conf
# Copy the daemon configuration file into place.
sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/
# Start Dnsmasq automatically.
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
echo "address=/dev/192.168.10.10" >> /usr/local/etc/dnsmasq.conf
#restart dnsmaq
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq
#make osx use dnsmasq
sudo mkdir -p /etc/resolver
sudo tee /etc/resolver/dev >/dev/null <<EOF
nameserver 127.0.0.1
EOF
After performing these steps you need to restart your mac. If you know some better way to active dnsmasq besides rebooting, let me know.
When your mac comes back up try pinging a random .dev domain.
With dnsmasq up and running you can .dev domains can be used in the homestead yaml file:
sites
- map: spatie.dev #no need to put this url in your hosts file
to: /home/vagrant/sites/spatie.be/public
function vm() {
cd ~/homestead
command="$1"
if [ "$command" = "edit" ]; then
open ~/.homestead/homestead.yaml
else
if [ -z "$command" ]; then
command="ssh"
fi
eval "vagrant ${command}"
fi
#switch back to directory where command was performed in
cd -
}
When this function is loaded these commands can be executed from every directory.
folders
- map: ~/.dotfiles
to: /home/vagrant/.dotfiles
Syncing the folder is not enough. The steps you need to perform to load the dotfiles on the host machine should be executed in homestead as well. In case of my dotfiles, the minimum that should be done is symlinking the .zshrc-file
ln -s $HOME/.dotfiles/shell/.zshrc $HOME/.zshrc
This is the result when using my dotfiles:
[caption id="attachment_1937" align="alignnone" width="1224"]
My custom zsh promt is visible inside homestead. The "a"-alias (short for "php artisan" is working)[/caption]
Do you have some homestead tips to share? Let me know in the comments below.
An awesome collection of Laravel tricks shared by Yitzchok Willroth aka Coderabbi at php[world]. He even includes some Laravel 5.2 specific tips.
When working on JavaScript code you'll probably find yourself riddling the code with console.log-statements when something is not working the way that you're expecting.
But did you know that there is a debugger statement available? It has invokes any available debugging functionality. To put it otherwise: you can programmatically set a breakpoint for your debugger. It should work in any browser.
function potentiallyBuggyCode() {
debugger; //the debugger wil stop here
}