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-linksadded 27 packages, and audited 28 packages in 10s6 packages are looking for funding run `npm fund` for detailsfound 0 vulnerabilitiesnpm noticenpm notice New major version of npm available! 8.18.0 -> 9.1.2npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.1.2npm 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.