关于php:How-to-develop-locally-a-Laravel-app-using-Laragon

6次阅读

共计 5870 个字符,预计需要花费 15 分钟才能阅读完成。

Source:# How to develop locally a Laravel app using Laragon

In this article I’ll show you how to develop locally a new Laravel app using Laragon.

在这篇文章中我将会向你展现如何用 Laragon 部署一个本地的 Laravel 我的项目

What is Laravel?Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
什么是 Laravel?Laravel 是一个具备表现力的,优雅的语法的 Web 利用框架。所有的小事件都曾经被框架筹备好了,用户只须要应用去自在发明

In the far 2017 I wrote an article about how to setup Laravel Homestead: the process is not as quick and easy as you can wish but following each step you can end up with a working development environment for Laravel. At that time, Laragon was already 2 years old but I never heard anything about it. And other 2 years should go by before I see the Laragon light.

早在 2017 年作者就编写了一篇如何设置 Laravel Homestead 的文章,然而搭建的过程并不是非常简单疾速,这时候 Largon 曾经进去 2 年了,然而这期间作者没有据说过 Largon 的任何音讯,直到 2 年后作者发现并且发现了它的闪光点并且疾速体验一波(于是这篇文章就呈现了)。

这种感觉相似 JAVAER 拿着 Eclipse 开发了几年忽然发现 IDEA 的新大陆一样。

What is Largon?Laragon is a portable, isolated, fast & powerful universal development environment for PHP, Node.js, Python, Java, Go, Ruby.

什么是 Largon?Laragon 是一个可移植的、隔离的、疾速和弱小的通用开发环境,实用于 PHP、Node.js、Python、Java、Go 和 Ruby。

In just a few clicks it will install in your Windows machine everything you need to develop web applications in your local environment: Apache, Nginx, MySql and more (for a full detailed list refer to Laragon page, please)

Largon 主页地址:Laragon – portable, isolated, fast & powerful universal development environment for PHP, Node.js, Python, Java, Go, Ruby.

只须要简略的点击几下装置按钮就能够装置你在本地环境下开发 Web 应用程序所需的所有。包裹 Apach、Nginx、NodeJs…..

这里吐槽一下 Largon 的图标有点像是 Postgresql 图标的侧面:

为啥老外都喜爱 Elephant?

题外话:这里扯一下题外话整点科普,大象 是迄今为止被证实的惟一一种通过额定的 p53 基因来抵挡癌症的动物,也就意味着大象无论活多久工夫,他的身材器官始终都是非常衰弱的,而大象的死亡看上去没来由的忽然倒下其实是寿命到头了,和咱们人类中衰弱并且长命的人寿命到了止境逝世是相似的,只是十分单纯的寿命到了止境。所以近几年医学界在尝试把大象的基因移植到人身上,希图反抗癌症。
感兴趣能够看看这篇文章:大象很少得癌是因为它们的细胞会他杀?– 纽约时报中文网 (nytimes.com)

闲扯到此结束,咱们接着翻译:

Unfortunately, Laragon is available only on Windows. if you use a Linux box and you wish to take a look at this wonderful tool, you can use one of these packages to run Windows software on Linux

可怜的是 Larragon 是一个纯 Windows 利用,不反对 Mac 或者 Linux,如果想要在 Linux 运行,则须要装置 GNU,也就是在 Linux 上模仿 Windows 的虚拟机,Ps:我感觉没啥必要。。。。。。

I want to show how easy it can be start to develop a new Laravel application using Laragon, and how to add Bootstrap to it

作者将会展现如何应用 Laragon 开发一个新的 Laravel 应用程序,以及如何在其中增加 Bootstrap。

留神最新版的 Largon 曾经不须要手动配置 NodeJs 和 Bootstrap,真正的开箱即用。

Step 1: install Laragon

Go to Laragon download page, download the latest version then just run the installer: _Next_, _Next_, _Next_…
Laragon starts instantly and I recommend to set it up to run when Windows starts.

Winodws 零碎进入到官网网址:Laragon download page 装置即可,集体倡议装置完整版,感兴趣能够装置便携版本。

Step 2: create a Laravel application

Just a right click on the Laragon window or on the Laragon tray icon to open a rich menu: just click on Quick app->Laravel

创立一个 Laravel 我的项目,只须要右键点击 Largon 的图标,而后选中 Quick app 的菜单,之后新建 Laravel 我的项目即可

因为某种神秘力量存在,在国内的环境下下载框架的相干包比较慢。所以咱们能够手动切换到国内的镜像仓库。

composer 更换为国内镜像 (laragon 自带 composer)
国内:composer config -g repo.packagist composer https://packagist.phpcomposer…
或者换成阿里有的:composer config -g repo.packagist composer https://mirrors.aliyun.com/co…

尝试屡次之后,把 Laravel 框架我的项目胜利初始化。

拜访 http://localhost/(默认 80 端口)能够看到相干的页面。

Sometimes, in Windows the command prompt seems to stuck, with a blinking cursor in a black desert: if this is the case click on the Laravel tray icon and this should just fix the issue. Otherwise reload Laragon.

有时在 Windows 中命令提示符仿佛被卡住了,在一个彩色的方框中闪烁着光标:如果是这种状况,点击 Laravel 的托盘图标,这应该正好解决这个问题。否则,从新加载 Laragon 利用(或者重启电脑尝试)。

If you go to C:\laragon\etc\apache2\sites-enabled folder, you will see that Laragon has created a new configuration file called auto.laraone.test.conf. In this file is defined the Virtual Host for your new application. You can take a look just to see how Laragon works.

如果你去C:\laragon\etc\apache2\sites-enabled 文件夹,你会看到 Laragon 创立了一个名为 auto.laraone.test.conf 的新配置文件。在此文件中定义了新应用程序的虚拟主机。你能够看看拉拉贡是如何工作的。

咱们能够进入到作者所说的门路查看对应的,当然这里集体把 Largon 装置到别的磁盘,所以我的电脑门路是:E:\laragon\etc\apache2\sites-enabled

这里说一下疾速找文件夹的技巧:应用 Wox + everything,或者在 EveryThing 外面间接像是上面那样搜寻:

进入到页面之后,能够看到咱们应用 Largon 创立的我的项目都有对应的主动配置管理,这里抉择察看 auto.test.test.conf 的内容,具体的内容如下:

<VirtualHost *:80> 
    DocumentRoot "E:/laragon/www/test/public"
    ServerName test.test
    ServerAlias *.test.test
    <Directory "E:/laragon/www/test/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

# If you want to use SSL, enable it by going to Menu > Apache > SSL > Enabled

Step 3: install node_modules

Now Laravel is already installed and ready to start but I want to use Bootstrap and to install it I need to install npm first.

当初 Laravel 我的项目曾经新建好了,Largon 也能够失常运行,当初咱们想要退出 NodeJs 到 Laravel 中辅助开发。

The Windows command prompt should already be in your new application directory: if this is not the case, move there manually or just open a new command prompt in C:\laragon\www\laraone directory and type

下面这段话的简略了解是,咱们能够应用 Largon 的命令行工具,进入到新建的 Laravel 根门路外面应用 npm intall 命令装置相干的 modules,留神 能够不须要本地具备 NodeJs 环境,因为 Largon 外面内置了以后版本对应的最新的 NodeJs。

为了验证这个说法,咱们能够到 Largon 的 bin 目录查看内置的“组件”:

而后是依照下面的探讨,执行上面的命令即可:

npm install --no-bin-links

E:\laragon\www\start
λ npm install --no-bin-links

added 27 packages, and audited 28 packages in 10s

6 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 8.18.0 -> 9.1.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.1.2
npm notice Run npm install -g npm@9.1.2 to update!
npm notice

This installs node_modules in your application

这在应用程序就胜利装置了 node_modules。

Step 4: fix package.json

To install Bootstrap we just need to type some more commands in the command prompt:

装置 Bootstrap 咱们只须要在命令提示符中再输出一些命令。

a) composer require laravel/ui: it can takes some time
b) php artisan ui bootstrap : this will actually install bootstrap
c) as required, run npm install && npm run dev

a) 应用 Largon 的命令行工具进入到我的项目根目录,在 Laravel 我的项目的根门路执行composer require laravel/ui,这可能须要一些工夫。
b) php artisan ui bootstrap : 这将理论装置 bootstrap。
c) 依据须要, 运行 npm install && npm run dev

That’s all! Now Bootstrap is installed and all its stuff is in
C:\laragon\www\laraone\resources\sass\app.scss and in
C:\laragon\www\laraone\public\css\app.css.
Reload Laragon once ore time and type laraone.test in your browser.
Ready to go to write your code!

以上就是本文的全部内容,当初 Bootstrap 曾经装置好了,它所有的货色都在 C:\laragon\www\laraone\resources\sass\app.scss 和在C:\laragon\www\laraone\public\css\app.css。从新加载 Laragon 一次,在浏览器中输laraone.test

筹备好去写你的代码了!

FInally

Although the article is older, it is generally more applicable.

正文完
 0