Home Backend Development PHP Tutorial PHP框架Laravel学习心得体会_php实例

PHP框架Laravel学习心得体会_php实例

Jun 07, 2016 pm 05:11 PM
laravel framework php framework laravel

Laravel是一套简洁、优雅的PHP Web开发框架 (PHP Web Framework) 。在世界(不含中国)PHP框架的占有率超过40%。

自从接触PHP以来一直使用Yii,感觉Yii实现功能比较简单,是一个很不错的框架。最近由于工作的原因开始研究Laravel5,不得不说我在第一步安装就被坑着了,下面就是我痛苦的学习成果。Laravel对我来说完全是新东西,如果内容有误,烦请留言或QQ我,帮我纠正错误,感激不尽!!!

1.首先安装php,最好5.6以上版本

  (1)windows安装composer过程中需要指定php.exe的路径

  (2)linux安装composer过程中需要利用php-cli功能

2.安装composer

  (1)windows安装composer

       a.windows下载composer软件,然后next直到完成
       b.win+R => 输入cmd => 输入composer, 如果出现composer字体表示安装成功

  (2)linux安装composer

       a.$ curl -sS https://getcomposer.org/installer | php
       b.此时在~/.composer下应该会产生composer.phar 这个文件
       c.$ mv  composer.phar  /usr/local/bin/composer
       d.将composer.phar移动成/usr/local/bin/composer全局下,以后可以直接使用composer,而不需要php  composer.phar
       e.$ composer

3.修改composer镜像源(建议第一种)

   (1)将配置信息添加到 composer 的配置文件 config.json 中(系统全局配置)

    $composer config -g repositories.packagist composer http://packagist.phpcomposer.com

   (2)将配置信息添加到单个项目的 composer.json 文件中(单个项目配置) 

  注意最后几行repositories

{
   name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": ["framework", "laravel"],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=..",
    "laravel/framework": "..*"
  },
  "require-dev": {
    "fzaninotto/faker": "~.",
    "mockery/mockery": "..*",
    "phpunit/phpunit": "~.",
    "phpspec/phpspec": "~."
  },
  "autoload": {
    "classmap": [
      "database"
    ],
    "psr-": {
      "App\\": "app/"
    }
  },
  "autoload-dev": {
    "classmap": [
      "tests/TestCase.php"
    ]
  },
  "scripts": {
    "post-install-cmd": [
      "php artisan clear-compiled",
      "php artisan optimize"
    ],
    "pre-update-cmd": [
      "php artisan clear-compiled"
    ],
    "post-update-cmd": [
      "php artisan optimize"
    ],
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "php artisan key:generate"
    ]
  },
  "config": {
    "preferred-install": "dist"
  },
  "repositories": [
    {"type": "composer", "url": "http://packagist.phpcomposer.com"},
    {"packagist": false}
  ]
}
Copy after login

4.安装laravel

$ composer create-project laravel/laravel learnlaravel5

浏览器访问localhost/learnlaravel5/public,出现Laravel5表示laravel5安装成功

以上内容是小编给大家分享的PHP框架Laravel学习心得体会,本文写的不好,还请给位大侠给我提出宝贵意见,共同学习进步。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1262
29
C# Tutorial
1235
24
How to use model events (Model Events) in Laravel framework How to use model events (Model Events) in Laravel framework Jul 28, 2023 am 10:49 AM

How to use model events (ModelEvents) in Laravel framework Laravel framework provides many powerful features, one of which is model events (ModelEvents). Model events are a feature used in Laravel's EloquentORM (Object Relational Mapping) that allows developers to execute custom code when a specific action occurs on the model. In this article, we will explore how to use model events in the Laravel framework and provide a

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

How to learn Laravel How to learn Laravel for free How to learn Laravel How to learn Laravel for free Apr 18, 2025 pm 12:51 PM

Want to learn the Laravel framework, but suffer from no resources or economic pressure? This article provides you with free learning of Laravel, teaching you how to use resources such as online platforms, documents and community forums to lay a solid foundation for your PHP development journey from getting started to master.

Laravel framework skills sharing Laravel framework skills sharing Apr 18, 2025 pm 01:12 PM

In this era of continuous technological advancement, mastering advanced frameworks is crucial for modern programmers. This article will help you improve your development skills by sharing little-known techniques in the Laravel framework. Known for its elegant syntax and a wide range of features, this article will dig into its powerful features and provide practical tips and tricks to help you create efficient and maintainable web applications.

How to use Task Scheduler to execute scheduled tasks in the Laravel framework How to use Task Scheduler to execute scheduled tasks in the Laravel framework Jul 29, 2023 am 09:54 AM

How to use the task scheduler (TaskScheduler) to execute scheduled tasks in the Laravel framework. With the development of web applications, scheduled tasks play a crucial role in many scenarios. The Laravel framework provides a powerful task scheduler (TaskScheduler) function that can easily perform various scheduled tasks, such as generating reports, cleaning caches, sending emails, etc. This article will introduce how to use the task scheduler to execute scheduled tasks in the Laravel framework.

Use the PHP framework Laravel to develop an efficient blog system and provide high-quality blog resources Use the PHP framework Laravel to develop an efficient blog system and provide high-quality blog resources Jun 27, 2023 am 09:37 AM

With the popularization of the Internet, traditional writing methods are gradually being replaced, and people tend to write, read, and communicate through online platforms. In this information-centered era, it is very necessary to develop an efficient blog system and provide readers with high-quality blog resources. This article will introduce how to use the PHP framework Laravel to develop an efficient blog system. 1. Why choose Laravel framework? Laravel is an excellent PHP framework. It is simple, flexible, efficient and can reduce development time.

Develop efficient web applications using the Laravel framework Develop efficient web applications using the Laravel framework May 27, 2023 am 08:51 AM

With the rapid development of the Internet, Web applications are playing an increasingly important role in our lives. For developers, how to use efficient tools and frameworks to develop web applications is crucial. The Laravel framework is undoubtedly one of the efficient choices. This article will introduce the basic concepts and uses of the Laravel framework to help you quickly develop efficient web applications. 1. Basic concepts of the Laravel framework The Laravel framework is an open source web application framework based on the PHP language. it

How to use Queue function in Laravel framework How to use Queue function in Laravel framework Jul 28, 2023 pm 09:37 PM

How to use the queue (Queue) function in the Laravel framework Introduction: Queue (Queue) is a common asynchronous processing mechanism that plays an important role in web development. The Laravel framework provides powerful queue functions that can easily handle various background tasks, such as sending emails, generating reports, processing big data, etc. This article will introduce how to use the queue function in the Laravel framework, including queue configuration, task definition and execution, etc., and give corresponding code examples. 1. Configure the queue in

See all articles