I’ve gatherered and categorized the best packages in one page.Laravel News Links
How to build a Laravel app using the OpenAI API
https://tectalic.com/img/blog/openai/ogImg.png
Overview
This tutorial outlines how to build a web application that generates business name and tagline ideas using OpenAI.
Here’s a quick demo video:
The user nominates their business’ industry and a concept, and the app will generate a set of business name ideas using OpenAI’s GPT-3 model text-davinci-002
.
If you aren’t already familiar with OpenAI, it is a paid service that allows you to access AI models (including GPT-3) using a REST API.
Starter App
To help get up and running quickly, we have created a starter Laravel application that implements the above functionality including user interface elements.
The starter app is built using Laravel, Livewire and Tailwind CSS.
The starter app shows hard-coded results at the beginning, and you integrate it with OpenAI’s API to return live results.
This tutorial will guide you through how to integrate OpenAI into this starter app, however, the basic steps can also be followed with your own app if you prefer.
The tutorial uses the free Tectalic OpenAI API client for PHP to make the development process faster and minimise manual coding.
You can also find the final implementation here if you’d like to jump straight to the solution.
Requirements
To follow along, you will need the following:
- An OpenAI account. If you don’t already have one, go to openai.com and create an account.
- An already configured PHP development environment, including:
- PHP 8.0+
- composer
- git
- node and NPM
- A PHP-capable IDE such:
- Familiarity with your terminal/shell.
- Familiarity with Laravel will help but is not essential.
Build the User Interface
Clone the skeleton app from GitHub using the following terminal commands:
git clone https://github.com/tectalichq/the-ai-name-generator.git
cd the-ai-name-generator
At this point, you will have the Laravel skeleton app installed, with version 0.1 checked out.
Now we will build the JavaScript and CSS assets that are required:
npm install
npm run build
We are now ready to get started with integrating OpenAI into the application – read on for details.
Integrate the OpenAI API
Install the Tectalic OpenAI API Client
Install the Tectalic OpenAI API Client, following the installation instructions:
composer require tectalic/openai
The above command adds the package into our project.
Configure the OpenAI API Client
This step allows us to set up and easily access our OpenAI API Client from anywhere in our Laravel application.
Open your app/Providers/AppServiceProvider.php
file, and add the following highlighted code block to the existing register()
method:
<?php
public function register()
{
$this->app->singleton(\Tectalic\OpenAi\Client\Client::class, function ($app) {
if (\Tectalic\OpenAi\Manager::isGlobal()) {
// Tectalic OpenAI REST API Client already built.
return \Tectalic\OpenAi\Manager::access();
}
/**
* Build the Tectalic OpenAI REST API Client globally.
*/
$auth = new \Tectalic\OpenAi\Authentication(config('services.openai.token'));
$httpClient = new \GuzzleHttp\Client();
return \Tectalic\OpenAi\Manager::build($httpClient, $auth);
});
}
The above code does several things:
- It adds the OpenAI API Client (
Tectalic\OpenAi\Client\Client
) to the Laravel Service Container. - It configures the OpenAI API Client’s Authentication token based on a value in Laravel’s configuration (more on that in the following step).
- It configures the OpenAI API Client to use the already installed Guzzle HTTP Client for performing HTTP requests. Any other PSR-18 compatible HTTP client (such as the Symfony HTTP Client) could also be used.
Authenticating the OpenAI API Client
Next, we will add a Laravel configuration setting to our app so that the OpenAI API Client uses the specified API Token.
To do so, open your config/services.php
file, and add the following three green lines to the existing array:
<?php
return [
'openai' => [
'token' => env('OPENAI_TOKEN'),
],
];
Next, open the .env.example
file, and add the following line to it:
OPENAI_TOKEN=
Now copy .env.example
to .env
:
cp .env.example .env
Now go to your OpenAI API Keys page and create a new secret key.
Paste your actual secret key into your .env
file, so that the OPENAI_TOKEN
value is replaced with your unique OpenAI API key.
For example:
OPENAI_TOKEN=sk-1234
(where sk-1234
is your actual OpenAI secret API Key).
This means that any OpenAI API calls will be authenticated using your own OpenAI secret API Key from your .env
file.
Query the OpenAI API During the Form Submission Process
Logic and UI are separated
In the skeleton app, the App\Http\Livewire\NameGenerator
Livewire component is what implements the form and UI. While the generateNames()
method in the the app/Http/Livewire/NameGenerator.php
file holds the logic.
Prepare the request
In this example, we will be using the OpenAI create completions endpoint, which allows us to send a prompt to OpenAI, and OpenAI will respond with one or more completions that match our context.
For more details on this OpenAI API endpoint, please consult the OpenAI Documentation.
Open the app/Http/Livewire/NameGenerator.php
file, and find the generateNames()
method around line 300.
This method is executed whenever the user submits the form, so we will now modify this method so that it queries the OpenAI API instead of returning hard-coded results.
First of all, this method needs access to our OpenAI API Client, so we will modify the method signature as follows:
297 /**
298 * When the form is submitted.
299 */
300 public function generateNames(): void
300 public function generateNames(\Tectalic\OpenAi\Client $client): void
301 {
This change will instruct Laravel to use its Service Container to automatically inject an OpenAI API Client instance into this method when the form is submitted, allowing us to refer to it using $client
.
Next we will build an OpenAI prompt, based on the industry and concept chosen by the user in the form:
300 public function generateNames(\Tectalic\OpenAi\Client $client): void
301 {
302 $validated = $this->validate();
303
304 $this->clearValidation();
305
306 $prompt = sprintf(
307 'Give me a business name and tagline for a company in the %s industry with a %s concept',
308 $validated['industry'],
309 $validated['concept'],
310 );
If you’ve never designed an OpenAI prompt before, read OpenAI’s prompt design documentation.
Building the Request
Write the code that builds the actual API request that will be sent to the OpenAI create completions endpoint with the prompt from the previous step:
You can see from the above video that we use our OpenAI API Client instance ($client
) to access the completions API handler, then call the create completion API method.
The Tectalic API Client, when combined with an IDE such as PhpStorm, will show you code completion information as you type, making it simpler to understand which API Handlers and Methods are supported by the API Client.
This create completion API method expects one argument, a Tectalic\OpenAi\Models\Completions\CreateRequest
class instance. This PHP class contains all the properties that you can send to a create completion API request.
The structured nature of the request parameters makes it simpler to understand the structure and information required to send the request using only your IDE – you don’t need to spend time reading and understanding the create completion documentation.
In our particular case, we are using the following properties for the request:
Property | Description |
---|---|
model |
The text-davinci-007 OpenAI model. |
prompt |
The already assembled prompt ($prompt ). |
max_tokens |
We override the default token limit from 16 to 2048, which ensures that OpenAI can interpret our prompt. See here if you’d like to learn more about OpenAI tokens. |
prompt |
We set this to 5 so that we get 5 completions (choices) back from OpenAI. |
If you’d like more detail on the create completion API request parameters, please see here.
Sending the Request
Now that our request is assembled, it’s time to actually send the request to the OpenAI API endpoint:
As you can see, sending the request is as simple as calling the toModel()
method on our $request
instance.
Parsing the Response
The toModel()
function used in the previous step actually does two things:
- It sends the API request to OpenAI.
- It parses the raw API response from OpenAI, and returns it in a structured way – in this case a
Tectalic\OpenAi\Models\Completions\CreateResponse
class instance.
Behind the scenes, the method is also converting the request to a JSON formatted request, sending it to the correct OpenAI endpoint, and then parsing the raw JSON formatted response, ensuring that it matches the expected format.
This structured response object makes it simpler to understand the structure and information in the OpenAI response – without needing to spend time reading the create completion response documentation.
It also enables static analysis tools for PHP, such as PHPStan or Psalm, which helps detect errors such as typos without the code being executed.
Choosing the Relevant Data From the Response
Now that we have sent the API request to OpenAI and retrieved the response, it is time to choose the relevant data from the OpenAI response and display it to our user:
The structured response objects mean you can use IDE code completion suggestions to understand what information is returned from OpenAI.
From the OpenAI response, we are only interested in the text
property from the choices
objects.
We use Laravel’s Array Map helper to iterate over the OpenAI response and return a simple array of result text(s).
These choices are saved to the names
class property on our Livewire Component, which Livewire then automatically displays to our user in the Results section of the user interface.
Error Handling
The above implementation should be working, so if you were to run your app at this point, everything should work as expected. Phew!
However, we’ve only considered and implemented the successful (happy) path – we haven’t yet handled the unsuccessful (unhappy) path(s) for our API integration, including scenarios such as:
- OpenAI’s API is temporarily inaccessible or unavailable.
- A communication issue between your application and OpenAI’s API occurs.
- OpenAI’s API returns an error code such as a 400 Bad Request (in the case that the request is invalid).
The following video demonstrates a simple method to handle these error scenarios gracefully:
This error handling is relatively straightforward to implement because the Tectalic OpenAI API Client automatically throws an Exception when errors occur. Specifically, a Tectalic\OpenAi\Exception\ClientException
is thrown. Consult the error handling documentation for details.
In this case, we add try
/catch
block to our code, and then return a friendly error message to our user if an error does occur.
The Final Implementation
In case you need it, below is the final implementation, with code additions highlighted in green and code removals highlighted in red.
You can also find the implementation in the develop
branch on GitHub.
composer.json
:
13 "laravel/tinker": "^2.7",
14 "livewire/livewire": "^2.10"
14 "livewire/livewire": "^2.10",
15 "tectalic/openai": "^1.0.0"
16 },
.env.example
59
60# OpenAI API Token
61OPENAI_TOKEN=
.env
59
60# OpenAI API Token
61OPENAI_TOKEN=sk-1234
(where sk-1234
is your actual OpenAI secret API Key).
config/services.php
:
24 'openai' => [
25 'token' => env('OPENAI_TOKEN'),
26 ],
app/Providers/AppServiceProvider.php
:
18 public function register()
19 {
20 $this->app->singleton(\Tectalic\OpenAi\Client\Client::class, function ($app) {
21 if (\Tectalic\OpenAi\Manager::isGlobal()) {
22 // Tectalic OpenAI REST API Client already built.
23 return \Tectalic\OpenAi\Manager::access();
24 }
25 /**
26 * Build the Tectalic OpenAI REST API Client globally.
28 */
29 $auth = new \Tectalic\OpenAi\Authentication(config('services.openai.token'));
30 $httpClient = new \GuzzleHttp\Client();
31 return \Tectalic\OpenAi\Manager::build($httpClient, $auth);
32 });
33 }
app/Http/Livewire/NameGenerator.php
:
297 /**
298 * When the form is submitted.
299 */
300 public function generateNames(): void
300 public function generateNames(\Tectalic\OpenAi\Client $client): void
301 {
302 $validated = $this->validate();
303
304 $this->clearValidation();
305
306 $prompt = sprintf(
307 'Give me a business name and tagline for a company in the %s industry with a %s concept',
308 $validated['industry'],
309 $validated['concept'],
310 );
311
312 $request = $client->completions()->create(
313 new \Tectalic\OpenAi\Models\Completions\CreateRequest([
314 'model' => 'text-davinci-002',
315 'prompt' => $prompt,
316 'max_tokens' => 2048,
317 'n' => 5 // 5 completions
318 ])
319 );
320
321 try {
322 /** @var \Tectalic\OpenAi\Models\Completions\CreateResponse $result */
323 $result = $request->toModel();
324 // Transform the result, as we only need to use the text from each completion choice.
325 $this->names = \Illuminate\Support\Arr::map($result->choices, function (\Tectalic\OpenAi\Models\Completions\CreateResponseChoicesItem $item) {
326 return $item->text;
327 });
328 } catch (\Tectalic\OpenAi\Exception\ClientException $e) {
329 // Error querying OpenAI.
330 // Clear any existing results and display an error message.
331 $this->reset(['names']);
332 $this->addError('results', __('Results are temporarily unavailable. Please try again later.'));
333 }
334 }
Run Your App
At this point, we will run our app and give it a try in our web browser:
Congratulations – we’re done!
The app should now be fully functional. Take a few minutes to experiment with various industries and concepts, and entertain yourself with the results.
Laravel News Links
Your Mac Has a Hidden White Noise Generator
https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/a1c777020d9b1f9dd584d56f5350bba7.jpg
If you want to drown out environmental noise, or you just like having white noise in the background while you work, you should try your Mac’s white noise generator. The feature is actually built into every Mac that runs macOS Ventura, you just need to know where to find it.
How to enable Background Sounds on macOS Ventura
You can find the white noise generator in your Mac’s settings menu. Click the Apple logo in the top-left corner of the screen and select System Settings. Next, select Accessibility in the left sidebar and click Audio in the right pane. Go to the Background Sounds section to enable Background Sounds. Once you’ve done that, you can select from a bunch of different sounds for your Mac. Click the Choose button next to Background Sound and you’ll see the following options:
- Balanced Noise
- Bright Noise
- Dark Noise
- Ocean
- Rain
- Stream
Hit the download button next to the sounds you want to download. That’ll save them to your Mac so you can also play them if you’re offline.
On the previous settings page, there are a couple useful options you should also check out. The first is Background Sounds Volume, which lets you set the volume level for the audio files. Once you’ve picked a comfortable volume, enable Turn off Background Sounds when your Mac is not in use. This setting will stop the sounds when your Mac goes to sleep.
How to generate white noise on older versions of macOS
Unfortunately, Apple’s Background Sounds feature is restricted to the Macs that can run Ventura. If you have an older Mac, you can use other tools to play white noise in the background. Music streaming services usually have a pretty good collection of white noise. Here are some examples on Spotify, Apple Music, and YouTube. Alternatively, you can try white noise apps such as Noizio.
Lifehacker
Keychron Q8 Review: Outstanding Ergonomic Keyboard Will Help You Type Faster
https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2022/11/keychron-q8-editors-choice.jpg
Do your hands and wrists hurt after a long day at your keyboard? It’s time to change things up, and Keychron’s Q8 Alice-style ergonomic keyboard could be just what you need. The ergonomic layout takes a minute for your fingers to get up to speed with, but when they do, you’re rewarded with a faster and more comfortable typing experience, and that’s well worth the outlay for this well-built, high-quality mechanical keyboard.
- Brand: Keychron Q8
- Backlight: Yes
- Media Controls: Optional knob, media controls via function buttons
- Switch Type: Gateron G-Pro, MX-compatible
- Replaceable Keys: Yes
- Number of Keys: 65%
- Compatible Devices: Windows, macOS, Linux
- Wired operation: USB-C
- Dimensions: 136mm x 358mm (5.4 inches x 14.1 inches)
- Weight : 1.82kg (4lbs)
- Excellent, sturdy build
- Ergonomic design good for typing
- Extensive customization options
- Great value
- No adjustable feet
- Customization software is a little complicated
When people ask me what the best mechanical keyboard is, it isn’t always a straightforward answer. Do you want clicky switches? And more to the point, how many keys do you want?
But now, with the Keychron Q8, we can ask the more surprising question: have you tried a keyboard with two B keys?
Unsurprisingly, most haven’t, but the Keychron Q8 hot-swappable 65% Alice keyboard gives newcomers to ergonomic typing that chance, and what a chance it is. Coming with Keychron’s now trademark sturdy build quality, the Keychron Q8 is a high-quality mechanical keyboard with several unique features that set it apart from the chasing pack—and it’s high time to give an Alice board a chance.
Keychron Q8 Configuration
Now, if you’re unsure about what an Alice keyboard is, check out the image below.
Notice how the keyboard is split in half? The idea is that splitting the keyboard into two distinct sections boosts your writing output while reducing the strain on your fingers and wrists while you tap away. The sections are roughly similar in size, though there are differences between left and right in terms of additional function keys and so on.
Part of the changes also comes from the overall number of keys. Keychron’s Q8 Alice board doesn’t feature the traditional function keys, thereby reducing the size (it’s a 65% keyboard), but it does have one really intriguing feature: two B keys. While this sounds odd, it makes sense once you begin using the Keychron Q8 and learning its new layout.
On that, it will take you a little while to figure out where your fingers should be, as where they probably want to be will result in spelling mistakes and other issues. Still, it doesn’t take long to get up to speed, and the benefits of switching are well worth the few days of hitting backspace more than usual.
In terms of configuration, like other Keychron mechanical keyboards, the Q8 comes with numerous design configurations ranging from bare-bones to completely constructed. We’re reviewing the Keychron Q8 Fully Assembled Knob version, which comes fully assembled with the additional volume control dial, retailing for $205. The fully assembled knobless version is $10 cheaper, at $195, while a barebones version of the Q8 costs $175.
Keychron Q8 Design
The Q8 uses an ergonomic design meant to reduce strain on your hands and wrists while typing. While the Alice configuration isn’t truly ergonomic, as it lacks the telltale giant curve at the bottom of the board, the shift in typing angle works well and certainly reduces strain and promotes a more regular hand and arm position when typing. Note that there is a slight curve to accommodate the changed key layout, but it’s not as pronounced as you’ll find elsewhere. But, in terms of talking about the form factor of the keys, that’s actually all there is to it.
More interesting is the substantial effort Keychron puts into manufacturing these fully CNC-machined mechanical keyboards. As with Keychron’s other mechanical boards, the Q8 is a solid piece of kit, weighing 1.82kg (4lbs). You wouldn’t want to drop it on your toe, that’s for sure, but the Keychron Q8’s weight comes from its excellent build quality, and you’re unlikely to be using the Q8 as a portable option anyway.
You should also note that the Q8 includes a solid steel plate for additional support in its multi-layered construction, adding some stability to the keyboard. There’s also a sound-absorbing foam layer to dampen keystrokes, managing to reduce the noise from even the most aggressive typers.
As above, the Keychron Q8 is a 65% keyboard, which means it has a smaller footprint than larger alternatives. The Keychron Q8 measures 136mm x 358mm (5.4 inches x 14.1 inches), while the case rises from 19.8mm (0.78 inches) at the front to 31.5mm (1.24 inches) at the rear. However, I found the five-degree incline way too flat for my liking (as have done with other Keychron boards—it’s me, not them), so used a pair of magnetic feet to boost the pitch somewhat. Wondering why I had to use magnetic feet?
The Q8 doesn’t come with integrated adjustable feet, which is somewhat irritating, but I can understand why they were omitted in favor of a smooth, easy-to-manufacture base.
A wrist rest would also be welcome, and it would be really cool if the wrist rest could match up with the slight curvature at the bottom of the board. I have a wrist rest to use, but it really would be handy, and look the part if it matched the actual keyboard. However, maybe that’s being picky.
Keychron Q8 Customization Options
Customization is at the core of all Keychron keyboards, and the Keychron Q8 is no different. You have the option to switch out the hot-swappable switches, change the excellent double-shot PBT keycaps, or delve into keyboard customization using the handy QMK customization software. It all adds up to a mechanical keyboard that comes out of the box looking like it does on the sales page, but one that you can really make feel your own.
If you’ve never tried hot-swappable switches, simply put, you should. Regular mechanical keyboard switches are soldered into place. You can remove them, but it takes time, effort, and tools, and comes with the fear you might damage something during the process. Whereas hot-swappable switches are the exact opposite; you don’t even need to turn the keyboard off while you switch them out. Keychron provides a handy keycap puller and key switch puller so you can get stuck into your keyboard switches. The Keychron Q8 is compatible with any MX-style switch, which gives you a really extensive range of keyboard switch options.
By the way, I say “stuck in,” but do be careful as bent mechanical keyboard switch pins are frustrating, and they are very small and potentially fragile.
Keychron Q8 customization also comes through the QMK VIA desktop software, a package featuring controls for your RGB lighting, keybinds, macros, and much more. Once you fire the software up, you’re presented with a schematic of your Q8, and you can switch between the various options in the side panel to adjust the various settings.
Furthermore, as the Keychron Q8 is compatible with both Windows and macOS, there are four “layers,” with two layers assigned to each operating system. You can add specific keybindings for each operating system from the extensive list of preset buttons in the menu below the keyboard, then save your customizations to the Q8, and you’re good to go. On that, you’ll also note that there is a macOS/Windows switch at the back of the keyboard for easy switching.
Download: VIA for Windows, macOS, Linux (Free)
If the VIA customization software doesn’t recognize your Keychron Q8 automatically, you’ll need to head to Keychron’s JSON file list and download the correct JSON file for your layout. Once downloaded, open the JSON file using VIA, and it’ll import your keyboard layout, customization options, and more.
Should You Buy the Keychron Q8 Alice-Style Mechanical Keyboard?
In the first few days using the Keychron Q8, my fingers were a little frustrated. When you write heaps every day, writing fast and with precision is important. Hitting the backspace key is tantamount to microseconds lost, and they add up throughout the day.
The Keychron Q8s ergonomic design does take a moment to become accustomed to. Your fingers will naturally divert to their tried and tested touch typing positions; it’s understandable. But when you do crack the adjustment to the slanted keys of the Alice-style layout, you’re rewarded with a smooth and fast typing experience that, for me, does what it says on the tin. My wrists and fingers are more comfortable using this layout, there is no doubt about it. My overall typing speed has also slightly increased, which is also a massive gain.
So from that perspective, the Keychron Q8 is a clear winner.
But consider the quality of the Keychron Q8, too. The CNC-machined body and multi-layer construction deliver quality throughout and is a core part of what makes the Keychron Q8 typing experience so good.
Outside building a fully customized mechanical keyboard yourself, the Keychron Q8 (and other Keychron keyboards) is the perfect middle ground for those that want better build quality and extensive customization without spending a fortune. Moreover, if you’re someone that spends all day typing, the Keychron Q8’s Alice-style ergonomic design will help with wrist and hand pain and could even help you type faster. What’s not to love?
MUO – Feed
Ramsey UUID Adds Support for v8
https://laravelnews.s3.amazonaws.com/images/uuidv8-featured.png
The popular PHP UUID library by Ben Ramsey released a new version with support for UUID v8, custom UUIDs.
The post Ramsey UUID Adds Support for v8 appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Laravel News
Taylor Otwell: 20+ Questions/Answers About Laravel – 2022 Edition
https://laraveldaily.com/storage/140/Untitled-design-(60).png
Recently Taylor Otwell answered a few dozen of questions from the community, on a live YouTube AMA video hosted by Adeva. In this article, I’ve tried to summarize the most interesting ones.
I’ve picked 11 questions, adding a few relevant links for the context. But there are many more questions answered by Taylor, so I still advise you to watch the full 1-hour video.
Are there still pain points that you are trying to solve?
There are still pain points that we see, even 12 years later. Like, recently we released a new syntax for defining Mailable objects. I felt that pain point personally, I just didn’t enjoy how they looked or how they were structured.
And then, of course, we get around 8-10 pull requests every day, and those usually address some pain points.
Do you have some approach to get feedback from people? Some structured way?
Not really. Sometimes we just ask for feedback on Twitter, we also receive feedback on GitHub. Sometimes, when I work on a feature, I make a Pull Request and then post it on Twitter and ask for feedback.
We don’t have a board where you can vote or anything like that.
Is Laravel scalable?
I think so. I hope so 🙂
There are mainly two ways to scale Laravel projects: through load balancers, with help of Forge, or serverless with auto-scaling, with help of Vapor, using the Amazon ecosystem tools.
People use Laravel to run very high-scale applications, like Fathom Analytics with loads of traffic.
What’s the status of Beep? Will it ever get released?
For some context, it was a team productivity app I was building with Laravel, I teased it on Twitter with the intention to open-source it.
It was more of a fun project to try things out, but I just could never get it how I wanted.
I still want to try beep with the upcoming Livewire 3. I haven’t totally given up on Beep, so we’ll see about the release.
What feature of Laravel was the hardest to implement?
Definitely Eloquent. I’ve rewritten Eloquent probably 3 or 4 times. It’s a case when the first 80% of the feature are fast to code, and the last 20% are extremely hard and complicated.
Every time I get a pull request to Eloquent, I have to admit I’m a bit scared to go review it.
Why is Valet no longer featured in the version v9 docs?
I was working on the docs, and it felt like we had so many different ways to install laravel. So instead of saying “You can use Valet, or Homestead, or Docker, or Artisan Serve…”, I wanted to change it, because it felt very overwhelming for someone new.
I actually still use Valet, I love Valet, and Valet is still on the sidebar in the tools.
Would you consider bringing InertiaJS into the Laravel family?
Jonathan and I have been talking about it. I actually have rewritten all Inertia docs and sent it to Jonathan a few months ago, and it should be released with Inertia 1.0.
I think we will help to maintain it and work on it more, as Jonathan now works at Tailwind and doesn’t have that much time for Inertia, so we will adopt that project a bit more.
About Tailwind vs Bootstrap
We use Tailwind at Laravel, we don’t use Bootstrap at all, and we want to use the things that we use and like ourselves.
It has been a controversial decision to switch to Tailwind because people like Bootstrap components like “card” or “alert”. So we still continue to maintain Laravel UI package which still uses Bootstrap 5, and we will continue maintaining that.
I wouldn’t be opposed to the Laravel Breeze version in Bootstrap but I need help, I just wouldn’t know how to do it myself, I haven’t worked with Bootstrap for 4 or 5 years.
What excites you the most in the PHP world right now?
I’m excited that people experiment more with Swoole or Roadrunner alternatives, which we use in Laravel Octane.
For Laravel 10, we’re working on a project to add more type hints and return types to methods, that’s another thing I’m excited about in Laravel 10.
Do you think Laravel deserves a built-in Permission Manager?
Maybe. I know there are some packages built by other people, but maybe we could create an official package in the future.
That’s an interesting phenomenon: even if some package already exists and it’s good, people still want it to be written by Laravel. But it would be overwhelming to maintain 100 packages.
What are some of the best decisions you made that helped Laravel really hit off?
Being friends with Jeffrey Way and Dayle Rees 🙂 Actually, other people made Laravel take off maybe more than I did. They helped recruit people into the Laravel world.
That’s it for the summary, watch the full 1-hour video here.
Laravel News Links
Are You Nuts? Know your Fishing Knots! – TN Knot
https://www.alloutdoor.com/wp-content/uploads/2022/11/20221104_140302-e1667602358976.jpg
This is an interesting knot that comes out of Japan, besides that I don’t know too much of it’s history for certain. I found it a few years back online when I originally started slow-pitch jigging. The TN Knot was either made by Norihiro Sato or just recommended by him, either way, this is my go-to knot when connecting to a swivel when I go jigging offshore. The knot has incredible strength and abrasion resistance which is critical in slow-pitch jigging when everything is already being worked to their limits. From a technical stand point, this is a very easy knot to tie, but when you actually tie it’s pretty involved. Now I’m not saying this to dissuade you from tying this knot just so you know you won’t get it on your first try.
Step 1
Run the line through the eye of the hook
Step 2
Run the tag end of the line through the eye of the hook two more times being careful not to overlap the line on itself as you do that.
Step 3
Take the tag end of the line then run it around the mainline and then through the two original loops that were made in Step 2 and then through the third loop that was just made.
Step 4
Then pull the knot tight, and make sure again the loops are not overlapping again.
Step 5
Then start making alternating half-hitch knots using the tag end of the line. You want to stack them up, making sure the first few are very tight as you do this. Keep everything tight and straight as you do this.
Step 6
Once you do 15 half-hitch knots, clip the tag end and use a lighter to bubble the tip of the tag end. Be careful to not burn your mainline but once this is done, your TN Knot is complete and ready to jig whatever your heart desires.
The post Are You Nuts? Know your Fishing Knots! – TN Knot appeared first on AllOutdoor.com.
AllOutdoor.com
EZQuest multiport hub review: More USB-C ports please
https://photos5.appleinsider.com/gallery/51205-101159-ezquest-hub-header-xl.jpg
AppleInsider may earn an affiliate commission on purchases made through links on our site.
The Ultimate Plus Multimedia Hub Adapter from EZQuest is the one-stop shop for almost any port people need in their computing life, and it’s geared toward Macs with Apple Silicon.
The EZQuest Hub works with Intel, M-Series Macs, and Windows PCs to connect external displays, USB-C devices, and more. It’s especially suited for MacBooks that have a limited number of ports.
EZQuest Hub Specifications
The hub has 13 ports to cover USB, audio, and video ports. For input, it has a USB-C Thunderbolt 4 port, while the output ports include one HMDI at 4K, one HDMI at 4K 60Hz, and a VGA 1080p 60Hz port.
It also has USB-C Power Delivery with passthrough charging up to 100W, one gigabit Ethernet port, four 5Gbps USB-A 3.0 ports, and a 3.5mm audio jack that also supports microphones.
For memory cards, there’s also one reader each for SD and Micro SD cards, offering read speeds of up to 104MB/s and write speeds of up to 80MB/s.
Each port has a helpful label next to it for ease of use.
Design & Construction
The hub is made of aluminum and is just under six inches in depth and width and one inch in height. We always like to see products constructed of premium materials, such as metal, and the EZQuest Hub fits the bill.
The size could be better for portability, but it is ideal for those with spacious desks who need many ports for various devices. For example, plug in the included USB-C cable to supercharge a Mac or USB-C iPad.
Using the EZQuest Hub
The EZQuest Hub does exactly what it says on the box for connecting devices. The USB-C PD port is excellent for quickly charging devices, although we would have liked to see at least one more USB-C port.
The hub can handle up to three external displays so people can build out their home workstations. EZQuest provides a handy resolution chart to know what to expect, supporting up to three external extended or mirrored displays.
The M1 processor can run a single external display using Thunderbolt 4 with the embedded DisplayPort 1.4 spec beyond the integrated display on a MacBook, or beyond the HDMI display on a Mac mini.
The M1 Pro processor doubles that number, allowing users to attach up to two 6K resolution monitors at 60Hz. The M1 Max goes even further to connect up to three 6K resolution displays and one external display with up to 4K resolution at 60Hz.
Using the VGA port requires a driver installation, available along with manuals when the hub is plugged into the computer. A drive appears in Finder with everything needed for the Instant View driver.
We liked that the 3.5mm port supports audio and microphone input, and gamers and podcasters might find a use for it.
The four USB-A 3.0 ports can be excellent for some people, although we’re increasingly finding that most of our accessories have moved to USB-C, which is why we wanted to see more of that port on the hub.
We liked using the EZQuest Hub, although it’s a tad large for our preference. But it’s a great option at the price of $169.99. Of course, only some people need this many ports, but this hub is an excellent choice for those who do.
- Nice design
- USB-C PD at 100W
- Multiple ports for external displays
- Thunderbolt 4 support
- Only one USB-C output port
Rating: 4 out of 5
Where to Buy
AppleInsider News
Laravel Workflow
https://miro.medium.com/max/251/1*iDNCaKL8Ishw_3e5zVXeeA.pngAllows users to write long running persistent distributed workflows (orchestrations) powered by Laravel queues.Laravel News Links
Native UUID support in Laravel has arrived
In a recent addition native UUID support (and native ULID support) is added by Dries Vints. It’s a great addition for me, as in many applications I tend to favor UUIDs over incremental IDs. I won’t bother you with the discussion of UUIDs vs. incremental IDs in this blog post, but just take a look at the UUID implementation in Laravel.
UUID in Eloquent
As with a lot of functionality in Laravel, the UUID support is really easy to add to any model. Just add the HasUuids
trait:
use Illuminate\\Database\\Eloquent\\Concerns\\HasUuids;
use Illuminate\\Database\\Eloquent\\Model;
class Post extends Model
{
use HasUuids
}
When you create a model, it will automatically contain a UUID as a key. The trait will automatically set the keyType
property to string
and the getIncremeting
method to return false
.
By default, Laravel generates an ordered UUID with this trait.
For more information about those ordered UUID’s, read this blog by Italo Baeza Cabera. There’s currently a draft about new UUID types, which also contains a time ordered version.
Change the UUID type
As stated above, Laravel uses ordered UUIDs by default. If your application requires UUID V4 or even UUID V1, you’re able to achieve that with a small addition.
When you want to change the type of UUID used, you should override the newUniqueId
method from the trait with your own version:
public function newUniqueId()
{
return (string)Str::uuid();
}
This method can be added to the model. When you need this in all your models, you could create an abstract Model class:
abstract class AppModel
{
use HasUuids;
public function newUniqueId()
{
return (string)Str::uuid();
}
}
class Post extends AppModel
{
}
Issue with saving without events
With incremental IDs, the ID is generated by the database. So you will be able to save a model without providing an ID and the database will take care of that.
Some databases aren’t able to generate UUIDs by default (or not easily). That’s why this implementation uses the creating
Eloquent model event in the trait boot. This catches the event and sets the UUID for the unique ids. So the main difference is that the IDs are generated in the application instead of in the database.
Read this blog post of Simon Archer to learn more about booting traits with Eloquent.
A side effect of using the creating
model event is that it depends on these events. Laravel also offers functionality to save a model without triggering the events, with for example the saveQuietly
method. That method doesn’t trigger the model events. In this case, that would result in a model without a generated UUID.
So the code below will most likely result in a database error saying the id
field has no default value:
$post = new Post();
$post->title = 'UUID test';
$post->saveQuietly();
If you need to save a model without triggering the events, the solution is to provide the UUID yourself:
$post = new Post();
$post->id = (string)Str::orderedUuid();
$post->title = 'UUID test';
$post->saveQuietly();
When using mass assignment, this could mean you need to unguard the model or add the id
field to the $fillable
array.
You usually shouldn’t want to use the saveQuietly
methods, but in seeders for example, it could be handy.
TLDR
UUID support works as easily as possible, by just adding the HasUuids
trait to your models. Be aware that it requires the model events to be fired so saving the model quietly doesn’t provide a UUID to your model.
Laravel News Links