valet 安装_什么是Laravel Valet,为什么要大惊小怪?

valet 安装

Yesterday, Taylor Otwell released Laravel Valet.

昨天,泰勒·奥特威尔(Taylor Otwell) 发布了Laravel Valet

Valet icon

If you’re just interested in the broad strokes of what it is, who it’s for, and how it works, watch the funny (and slightly NSFW) video below. If you’d like to go more in depth and find out some more details about the product, and learn why it caused such a polarizing fuss on Reddit and Twitter, read on after the jump.

如果您只是对它的用途,用途和作用感兴趣,请观看下面的有趣视频(和NSFW)。 如果您想更深入地了解该产品的更多详细信息,并了解为什么它在Reddit和Twitter上引起如此大的争议,请在跳转后继续阅读。



中风 (Broad strokes)

Valet is a tool which makes spinning up demo or discardable projects a breeze.

Valet是一种使演示或废弃项目轻而易举的工具。

It’s a tool which combines some of the default software on OS X with some ideas about filepaths and serving of PHP apps, and some additional tools for skipping the need to modify the /etc/hosts file. Additionally, it allows for forwarding of access to the local application over the public internet when needed.

它是一个工具,将OS X上的某些默认软件与有关文件路径和PHP应用程序服务的一些思想结合在一起,并提供了一些其他工具,这些工具无需修改/etc/hosts文件。 此外,它允许在需要时通过公共Internet转发对本地应用程序的访问。

Unlike Vagrant or Docker It offers no isolation, making all apps use the same globally available software. Why this is important to note will be explained below.

Vagrant或Docker不同,它不提供隔离,使所有应用程序使用相同的全局可用软件。 为什么要注意这一点很重要,将在下面说明。

细节 (Particulars)

Let’s dive into the particulars, one by one.

让我们一一深入研究细节。

仅OS X (OS X only)

Valet is currently OS X only. This is currently the number one complaint from newcomers running into Valet.

代客目前仅适用于OSX。 目前,这是进入Valet的新移民的头号投诉。

While, technically, it should be possible to make it work on Linux given the amount of architecture the two systems share and the fact that most Linux distros have an old version of PHP pre-installed, Windows will likely never become an option without a full, OS-specific rewrite.

尽管从技术上讲,鉴于两个系统共享的体系结构量以及大多数Linux发行版已预装旧版本PHP的事实,应该有可能使其在Linux上运行,但如果没有完整的Windows版本,Windows可能永远不会成为一个选择。 ,特定于操作系统的重写。

It’s not a conspiracy. Taylor does not belong to the cult of Apple, and he isn’t trying to be elitist. It’s just very easy to develop projects like these for OS X because of a very good package manager (Homebrew) and sensible defaults already being pre-installed.

这不是阴谋。 泰勒(Taylor)不属于Apple的崇拜者,他也不想成为精英主义者。 由于OS X的软件包管理器(Homebrew)非常出色,并且已经预先安装了明智的默认设置,因此为OS X开发此类项目非常容易。

共享系统状态 (Shared system state)

Due to not using VMs or containers, Valet relies on the version of PHP installed on OS X. Not many people know this but OS X in fact ships with PHP pre-installed, though an admittedly outdated version (at the time of writing it defaults to 5.5.31). While that version is enough for running the most rudimentary applications, it’d be a shame not to use the most recent version.

由于不使用VM或容器,Valet依赖于OS X上安装PHP版本。很少有人知道这一点,但OS X实际上预装了PHP,尽管该版本已经过时(在撰写本文时为默认值)至5.5.31)。 尽管该版本足以运行最基本的应用程序,但不使用最新版本是可耻的。

To update to PHP7 on OS X using Homebrew, first install Homebrew and then run:

要使用Homebrew在OS X上更新到PHP7,请先安装Homebrew ,然后运行:

brew update
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php70
brew cleanup

Finally, make OS X execute the new PHP by default by adding the following line to your ~/.bash_profile file:

最后,通过~/.bash_profile下行添加到~/.bash_profile文件中,使OS X默认执行新PHP:

export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

Then, either relaunch your terminal windows or run source ~/.bash_profile for the change to take effect.

然后,重新启动终端窗口或运行source ~/.bash_profile以使更改生效。

在OS X上运行PHP 7

Note that you also need to have Composer installed globally for Valet to work.

请注意,您还需要全局安装Composer才能使Valet正常工作。

This is one of the major downsides of Valet, by the way, and akin to using MAMP or XAMPP and similar tools – all the apps will be using the same database / PHP version / extensions. That means the dependence on one can ruin other apps’ dependence on others. Be careful in starting serious projects with Valet!

顺便说一下,这是Valet的主要缺点之一,类似于使用MAMP或XAMPP以及类似的工具-所有应用程序都将使用相同的数据库/ PHP版本/扩展名。 这意味着对一个应用程序的依赖会破坏其他应用程序对其他应用程序的依赖。 在与代客开始严肃的项目时要小心!

自动虚拟主机 (Automatic virtual host)

Valet uses DnsMasq to simulate virtual hosts in that it takes any folder name you create with it and makes the app within accessible via a {foldername}.dev domain.

Valet使用DnsMasq来模拟虚拟主机,因为它可以使用您使用它创建的任何文件夹名称,并使其中的应用程序可以通过{foldername}.dev域进行访问。

For example, if you run valet park in a specific folder, Valet will search said folder for project setups matching the ones it supports and immediately make them accessible in the browser with the .dev suffix. Thus, creating a new Laravel project in ~/my-sites/laravel will make the site available on http://laravel.dev.

例如,如果您在特定文件夹中运行valet park ,代客将在该文件夹中搜索与其支持的项目设置匹配的项目设置, .dev即使它们在浏览器中带有.dev后缀。 因此,在~/my-sites/laravel创建一个新的Laravel项目将使该站点在http://laravel.dev上可用。

Note that for this to work, you do not need to touch etc/hosts at all, as opposed to the situation with Vagrant.

请注意,与Vagrant相比,完全不需要触摸etc/hosts

This makes previewing the demo apps you’re building much, much simpler, and completely skips the need for Apache or Nginx configuration – a tremendous headache for most people.

这使得预览您正在构建的演示应用程序变得非常简单得多,并且完全跳过了对Apache或Nginx配置的需求-对于大多数人来说,这是一个巨大的麻烦。

Valet uses .dev by default. While not in widespread use, .dev is actually a valid top level domain. Valet can be configured to use a different suffix, however. After installing it with Composer (preferably globally) enter its home folder and find the file config.json. There will be a domain key there with the value .dev. Changing this to something like .devlocal should do the trick.

代客默认使用.dev 尽管未广泛使用,但.dev实际上是有效的顶级域。 但是,可以将代客配置为使用其他后缀。 使用Composer(最好是全局安装)安装后,进入其主文件夹并找到文件config.json 那里会有一个domain密钥,其值为.dev 将其更改为.devlocal类的.devlocal可以解决问题。

开发/产品ASP (Dev / prod parity)

If you’ve read my book, you might be wondering “But what about dev / prod parity?”

如果您读过我的书 ,您可能会想:“但是,开发/产品平价呢?”

You’d be right to wonder – it’s quite a big deal. The environment you’re developing in this way is so far removed from any possible production environment, it’s practically ludicrous to expect anything to run the way it does during development. That’s why Valet is suitable only for:

您会想知道-这是很大的事情。 到目前为止,以这种方式开发的环境已与任何可能的生产环境相去甚远,期望任何东西都能像在开发期间那样运行实际上是荒谬的。 因此,代客仅适用于:

  • demo / throwaway projects

    演示/一次性项目
  • or, people who are absolutely certain they’ve configured their prod environment to match all the conditions of the app as developed under Valet

    或者, 完全可以确定自己已配置其产品环境以符合Valet开发的应用程序所有条件的人们

The latter is quite the impossibility, so I doubt we’ll see many serious, long term projects developed with Valet.

后者是完全不可能的,因此我怀疑我们会看到与Valet合作开发的许多严肃的长期项目。

供应商锁定(带有警告) (Vendor-lock (with a caveat))

Right now, Valet supports only the following types of applications:

目前,代客仅支持以下类型的应用程序:

This is because it relies on a specific file and folder layout to properly host things with the built-in PHP server. However, Valet does support custom drivers which allow for extending the tool and adding new ways to host alternative application structures.

这是因为它依赖于特定的文件和文件夹布局,以使用内置PHP服务器正确托管内容。 但是,代客确实支持自定义驱动程序 ,该驱动程序允许扩展工具并添加新方法来承载替代应用程序结构。

Keep this in mind when you try to run your custom application with it and find it not working!

当您尝试使用它运行自定义应用程序时,请记住这一点!

实时自托管预览 (Live self-hosted preview)

One of the major selling points of Valet is the ease with which one is able to share a work in progress with a client or another developer. Running valet share in an application’s folder will make it publicly available online via an automatically generated link. To stop sharing the site, simply stopping the service with Ctrl + C does the trick.

代客的主要卖点之一是可以轻松地与客户或其他开发商共享进行中的作品。 在应用程序的文件夹中运行valet share将使其通过自动生成的链接在线上公开可用。 要停止共享站点,只需使用Ctrl + C停止服务即可。

Behind the scened, Valet uses Ngrok to accomplish this.

在幕后,代客使用Ngrok完成此任务。

结论 (Conclusion)

Sure, the entire set of tools in Valet is something you can use on your own, too, but in typical Laravel fashion, many smaller, useful things have been put in one convenient package to make the entire process of developing and debugging an app much faster. After all, what is Laravel itself if not a collection of incredibly handy packages all wrapped up in one extremely practical whole?

当然,也可以自行使用Valet中的整套工具,但是以典型的Laravel方式,许多较小的有用的东西都放在一个方便的程序包中,以使开发和调试应用程序的整个过程变得更加简单。快点。 毕竟,Laravel本身如果不是将非常方便的软件包收集在一起并打包成一个非常实用的整体呢?

For more information about Laravel Valet, please see the documentation. We won’t be abandoning our Homestead Improved any time soon in favor of Valet (cross-platform friendliness is more important to us), but there’s definite value in Valet – from handy tools that expedite the sharing and self-hosting process to resource usage (only about 7MB of RAM!), Valet has a plethora of advantages over setups like MAMP or XAMPP.

有关Laravel Valet的更多信息,请参阅文档 。 我们不会很快放弃我们的宅基地改良 ,而代之以Valet(跨平台友好对我们更重要),但是Valet的确具有一定的价值-从可加快共享和自我托管过程的便捷工具到资源使用(只有大约7MB的RAM!),与诸如MAMP或XAMPP之类的设置相比,代客具有许多优势。

Will you be using it?

你会用吗?

翻译自: https://www.sitepoint.com/what-is-laravel-valet-and-why-all-the-fuss/

valet 安装

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值