Laravel 5 系列入门教程(一)【最适合中国人的 Laravel 教程】
基于最新 Laravel 5.5 的 2017 版教程已经发布到 Github:https://github.com/johnlui/Learn-Laravel-5/issues
十分建议学习 5.5,跟 5.0 比变化非常大。
本教程示例代码见:https://github.com/johnlui/Learn-Laravel-5
大家在任何地方卡住,最快捷的解决方式就是去看我的示例代码。
Laravel 5 中文文档:
1. http://laravel-china.org/docs/5.0
2. http://www.golaravel.com/laravel/docs/5.0/
默认条件
本文默认你已经有配置完善的 PHP + MySQL 运行环境,懂得 PHP 网站运行的基础知识。跟随本教程走完一遍,你将会得到一个基础的包含登录的简单 blog 系统,并将学会如何使用一些强大的 Laravel 插件和 composer 包(Laravel 插件也是 composer 包)。
软件版本:PHP 5.4+,MySQL 5.1+
本文不推荐完全不懂 PHP 与 MVC 编程的人学习。本文不是 “一步一步跟我做” 教程。本文需要你付出一定的心智去解决一些或大或小的隐藏任务,以达到真正理解 Laravel 运行逻辑的目的。
1. 安装
许多人被拦在了学习Laravel的第一步,安装。并不是因为安装教程有多复杂,而是因为【众所周知的原因】。在此我推荐一个composer全量中国镜像:http://pkg.phpcomposer.com/ 。推荐以 “修改 composer 的配置文件” 方式配置。
镜像配置完成后,切换到你想要放置该网站的目录下(如 C:\wwwroot、/Library/WebServer/Documents/、/var/www/html、/etc/nginx/html 等),运行命令:
composer create-project laravel/laravel learnlaravel5 5.0.22
然后,稍等片刻,当前目录下就会出现一个叫 learnlaravel5 的文件夹。
本系列教程使用 Laravel 5.0 版本,5.1 版本去掉了本系列教程主要讲解的元素(Auth 系统),不建议使用 5.1 来学习。本系列教程为入门教程,目的是搞清楚 Laravel 的基本使用方法,切忌本末倒置。
如果你不会配置,建议去学会配置,网上资料很多。如果自暴自弃,可以把 的第 29 行 'url' => 'http://localhost', 配置成你的子目录地址,注意,要一直配置到 */learnlaravel5/public。然后将网站根目录配置为 learnlaravel5/public。
使用浏览器访问你配置的地址,将看到以下画面(我在本地配置的地址为 http://fuck.io:88 ):
2. 体验 Auth 系统并完成安装
—— 经过上面的过程,Laravel 5 的安装成功了?
—— 没有o(╯□╰)o
查看路由文件 learnlaravel5/app/Http/routes.php
的代码:
Route::get('/', 'WelcomeController@index'); Route::get('home', 'HomeController@index'); Route::controllers([ 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController', ]);
跟随代码里的蛛丝马迹,让我们访问 http://fuck.io:88/home (请自行替换域名),结果竟然跳转到了登陆页?
没错,Laravel 自带了开箱即用的 Auth 系统,连页面都已经写好了。
让我们随意输入邮箱和密码,点击登录,你很可能得到以下画面(Mac 或 Linux 下):
为什么空白?用开发者工具查看,这个请求的状态码是 500,为什么?
因为
learnlaravel5/storage
目录没有 777 权限。
执行 shell 命令:
cd learnlaravel5 sudo chmod -R 777 storage
重新访问 http://fuck.io:88/home ,随意输入邮箱和密码,如果你得到以下画面:
那么恭喜你~ Laravel 5 安装成功!
不想配置镜像的同学,可以使用 Laravel 界非常著名的 安正超 搞的安装神器:https://github.com/overtrue/latest-laravel
3. 数据库建立及迁移
Laravel 5 把数据库配置的地方改到了 learnlaravel5/.env
,打开这个文件,编辑下面四项,修改为正确的信息:
DB_HOST=localhost DB_DATABASE=laravel5 DB_USERNAME=root DB_PASSWORD=password
推荐新建一个名为 laravel5 的数据库,为了学习方便,推荐使用 root 账户直接操作。
Laravel 已经为我们准备好了 Auth 部分的 migration,运行以下命令执行数据库迁移操作:
php artisan migrate
得到的结果如下:
如果你运行命令报错,请检查数据库连接设置。
至此,数据库迁移已完成,你可以打开 http://fuck.io:88/home 欢快地尝试注册、登录啦。
4. 模型 Models
接下来我们将接触Laravel最为强大的部分,Eloquent ORM,真正提高生产力的地方,借用库克的一句话:鹅妹子英!
运行一下命令:
php artisan make:model Article php artisan make:model Page
Laravel 4 时代,我们使用 Generator 插件来新建 Model。现在,Laravel 5 已经把 Generator 集成进了 Artisan。
现在,Artisan 帮我们在 learnlaravel5/app/
下创建了两个文件 Article.php
和 Page.php
,这是两个 Model 类,他们都继承了 Laravel Eloquent 提供的 Model 类 Illuminate\Database\Eloquent\Model
,且都在 \App
命名空间下。这里需要强调一下,用命令行的方式创建文件,和自己手动创建文件没有任何区别,你也可以尝试自己创建这两个 Model 类。
Model 即为 MVC 中的 M,翻译为 模型,负责跟数据库交互。在 Eloquent 中,数据库中每一张表对应着一个 Model 类(当然也可以对应多个)。
如果你从其他框架转过来,可能对这里一笔带过的 Model 部分很不适应,没办法,是因为 Eloquent 实在太强大了啦,真的没什么好做的,继承一下 Eloquent 类就能实现很多很多功能了。
如果你想深入地了解 Eloquent,可以阅读系列文章:深入理解 Laravel Eloquent(一)——基本概念及用法
接下来进行 Article 和 Page 类对应的 articles 表和 pages表的数据库迁移,进入 learnlaravel5/database/migrations
文件夹。
在 *_create_articles_table.php 中修改:
Schema::create('articles', function(Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('slug')->nullable(); $table->text('body')->nullable(); $table->string('image')->nullable(); $table->integer('user_id'); $table->timestamps(); });
在 *_create_pages_table.php 中修改:
Schema::create('pages', function(Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('slug')->nullable(); $table->text('body')->nullable(); $table->integer('user_id'); $table->timestamps(); });
然后执行命令:
php artisan migrate
成功以后, articles 表和 pages 表已经出现在了数据库里,去看看吧~
5. 数据库填充 Seeder
在 learnlaravel5/database/seeds/
下新建 PageTableSeeder.php
文件,内容如下:
delete(); for ($i=0; $i < 10; $i++) { Page::create([ 'title' => 'Title '.$i, 'slug' => 'first-page', 'body' => 'Body '.$i, 'user_id' => 1, ]); } } }
然后修改同一级目录下的 DatabaseSeeder.php
中:
// $this->call('UserTableSeeder');
这一句为
$this->call('PageTableSeeder');
然后运行命令进行数据填充:
composer dump-autoload php artisan db:seed
去看看 pages 表,是不是多了十行数据?
教程(一)代码快照:https://github.com/johnlui/Learn-Laravel-5/archive/tutorial_1.zip
下一步:Laravel 5 系列入门教程(二)【最适合中国人的 Laravel 教程】
评论:
2017-08-22 17:15
SQLSTATE[42S01]: Base table or view already exists: 1050 La table 'users' existe d茅j脿 (SQL
: create table `users` (`id` int unsigned not null auto_increment primary key, `name` varc
har(255) not null, `email` varchar(255) not null, `password` varchar(255) not null, `remem
ber_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) de
fault character set utf8mb4 collate utf8mb4_unicode_ci)
[PDOException]
SQLSTATE[42S01]: Base table or view already exists: 1050 La table 'users' existe
执行php artisan grate 报了上面的错误,如何避免呢
2017-04-01 17:01
Cannot declare class CreateUsersTable, because the name is already in use
这个是咋回事呢?我已经清空数据库了,说我那个名字已经在使用了,咋解决/我的事wamp64位,php7.0.1版本,laraval是5.2.15刚入手的,之前用过一下thinkphp。请大家指教一下。
2017-03-30 00:59
2016-07-15 18:25
Stack trace:
#0 /home/dong/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
thrown
大神这是什么意思?
2016-04-14 11:58
2016-04-02 21:41
2016-01-12 13:12
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? [y/N] y
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'
(SQL: create table `users` (`id` int unsigned not null auto_increment primary key, `name` varch
ar(255) not null, `email` varchar(255) not null, `password` varchar(60) not null, `remember_tok
en` varchar(100) null, `created_at` timestamp default 0 not null, `updated_at` timestamp defaul
t 0 not null) default character set utf8 collate utf8_unicode_ci)
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'
2016-01-11 18:30
'title' => 'Title '.$i,
'slug' => 'first-page',
'body' => 'Body '.$i,
'user_id' => 1,
]);
貌似这里有问题,应该改成下面的才能运行来着
DB::table('pages')->insert([
'title' => 'Title '.$i,
'slug' => 'first-page',
'body' => 'Body '.$i,
'user_id' => 1,
]);
2016-01-08 10:37
ReflectionException in Route.php line 264:
Class App\Http\Controllers\HomeController does not exist
in Route.php line 264
at ReflectionMethod->__construct('App\Http\Controllers\HomeController', 'index') in Route.php line 264
at Route->signatureParameters('Illuminate\Database\Eloquent\Model') in Router.php line 838
at Router->substituteImplicitBindings(object(Route)) in Router.php line 823
at Router->substituteBindings(object(Route)) in Router.php line 806
at Router->findRoute(object(Request)) in Router.php line 670
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53 。
能帮忙解答下吗?我的版本是5.2。
2016-01-04 15:26
[Illuminate\Database\QueryException]
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'title' in 'field li
st' (SQL: insert into `pages` (`title`, `slug`, `body`, `user_id`, `updated
_at`, `created_at`) values (Title 0, first-page, Body 0, 1, 2016-01-04 07:2
4:15, 2016-01-04 07:24:15))
[PDOException]
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'title' in 'field li
st'
2015-12-24 16:51
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' (SQL: create table `users` (`id` int unsigned not null auto_increment primary k
ey, `name` varchar(255) not null, `email` varchar(255) not null, `password` varchar(60) not null, `remember_token` varchar(100) null, `created_at` timestamp default 0 not nul
l, `updated_at` timestamp default 0 not null) default character set utf8 collate utf8_unicode_ci)
我在执行php artisan migrate的时候就一直报这个错是怎么回事啊。。
2015-12-14 17:21
2015-12-12 11:36
php artisan app:name larvael5
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class larvael5\Http\Kernel does not exist' in E:\www\13838\vendor\laravel\framework\src\Illuminate\Container\Container.php:776
Stack trace:
#0 E:\www\13838\vendor\laravel\framework\src\Illuminate\Container\Container.php(776): ReflectionClass->__construct('larvael5\\Http\\K...')
#1 E:\www\13838\vendor\laravel\framework\src\Illuminate\Container\Container.php(656): Illuminate\Container\Container->build('larvael5\\Http\\K...', Array)
#2 E:\www\13838\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(613): Illuminate\Container\Container->make('larvael5\\Http\\K...', Array)
#3 E:\www\13838\vendor\laravel\framework\src\Illuminate\Container\Container.php(229): Illuminate\Foundation\Application->make('larvael5\\Http\\K...', Array)
#4 E:\www\13838\vendor\laravel\framework\src\Illuminate\Container\Container.php(773): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminate\Foundation\Application), Array)
#5 E:\www\13838\vendor in E:\www\13838\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 776
请问怎么还原呢??
2015-12-08 11:05
D:\wamp\www\laravel>php artisan migrate
Fatal error: Call to undefined function Illuminate\Foundation\Bootstrap\mb_inter
nal_encoding() in D:\wamp\www\laravel\vendor\compiled.php on line 1809
报错,开启了mb_string扩展, 并且单独文件测试 mb_internal_ecoding函数没报错,一执行php artisan migrate 就报错,应该怎么解决呢
2015-12-03 09:51
为什么我在第三步最后,注册成功后,在数据库查看用户的密码是一堆类似乱码的杂乱符号呢? 而不是密码本身?
比如我注册一个用户,使用密码 123456 ,在数据库中查看就是一大长串字母加数字加符号,而我手动将数据库中的这个符号修改为 123456后
登录的时候会提示 Whoops! There were some problems with your input. These credentials do not match our records.
请问这可能是哪里出问题了呢?谢谢!
2015-11-22 13:20
input 文本之前的值没有 怎么回事
2015-11-15 11:37
2015-11-10 17:05
我按照步骤在执行php artisan migrate的时候出现了错误
[PDOException]
could not find driver
我的pdo_pgsql扩展是打开的
PDO
PDO support enabled
PDO drivers mysql, pgsql, sqlite
pdo_pgsql
PDO Driver for PostgreSQL enabled
PostgreSQL(libpq) Version 9.2.2
Module version 1.0.2
Revision $Id$
pgsql
PostgreSQL Support enabled
PostgreSQL(libpq) Version 9.2.2
PostgreSQL(libpq) Uninitialized version string (win32)
Multibyte character support enabled
SSL support disabled
Active Persistent Links 0
Active Links 0
Directive Local Value Master Value
pgsql.allow_persistent On On
pgsql.auto_reset_persistent Off Off
pgsql.ignore_notice Off Off
pgsql.log_notice Off Off
pgsql.max_links Unlimited Unlimited
pgsql.max_persistent Unlimited Unlimited
尝试了用PHP直接连postgresql正常,代码如下
<?php
$dsn = 'pgsql:dbname=kaigo;host=127.0.0.1;port=5432';
$user = 'kaigo';
$pass = 'kaigo';
try {
$dbh = new PDO($dsn, $user, $pass);
$sql = 'SELECT CURRENT_TIMESTAMP';
foreach ($dbh->query($sql) as $row) {
print $row[0] . "\n";
}
$dbh = null;
} catch (PDOException $e){
print('[ERROR] ' . $e->getMessage() . "\n");
die();
}
?>
.env文件数据库连接部分如下
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_DATABASE=kaigo
DB_USERNAME=kaigo
DB_PASSWORD=kaigo
database.php文件部分如下
'default' => 'pgsql',
'connections' => [
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'database' => env('DB_DATABASE', 'kaigo'),
'username' => env('DB_USERNAME', 'kaigo'),
'password' => env('DB_PASSWORD', 'kaigo'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
环境是win7 64位,wampserver2.5(apache 2.4.9+php 5.5.12),postgresql 9.2
如果是连接mysql和sqlite能够正常通过,连postgresql就会出现上面说的错误
按照网上说的将libpq.dll文件拷到了apache目录下依然没有用
请问该如何解决?
2015-11-09 15:10
[ReflectionException]
Class PageTableSeeder does not exist
2015-11-04 16:12
请问如何能有效的去除掉laravel5中的public、index.php
我之前只是将网站root下的server.php改名为index.php
这个只解决了一部分,比如访问www.com/laravel不再是以前的ww.com/laravel/public/index.php
但是别的部分,比如有页面跳转的情况,比如ww.com/page/1是server not fund
然而ww.com/index.php/page/1是可以访问页面
我已经把。htaccess里面的参数也修改了,还是没有起效
2015-10-28 19:22
http://120.25.106.144:8888/auth/login
2015-10-19 11:11
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
这是我看到的配置网站根目录的介绍,说是要配置到应用的根目录,可是应用的根目录不应该配置到learnlaravel5吗,
您为啥要配置到public呢
2015-10-02 10:01
PHP Fatal error: Call to undefined method PageTableSeeder::setContainer() in /home/opt/demos/lv_demo/laraveldemo/vendor/laravel/framework/src/Illuminate/Database/Seeder.php on line 57
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method PageTableSeeder::setContainer()
2015-10-01 21:03
Method [validator] does not exist. 为什么?
2015-09-23 12:53
我 composer update了
但运行还是Whoops, looks like something went wrong.
1/1 FatalErrorException in routes.php line 15: Call to undefined method Illuminate\Routing\Route::get()
还有就是 composer update 有什么作用呢
2015-09-23 10:49
我这个 Route::get('/', 'WelcomeController@index');
<?php namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class WelcomeController extends Controller {
public function index()
{
return View::make('welcome');
}
}
运行时
Whoops, looks like something went wrong.
1/1 FatalErrorException in routes.php line 18: Call to undefined method Illuminate\Routing\Route::get()
我是不是哪里 弄错了
2015-09-21 10:38
DB_DATABASE=laravel5
DB_USERNAME=root
DB_PASSWORD=123456
数据库用户名,密码都改了,执行php artisan migrate报错SQLSTATE[HY000] [1045] Access denied for user ‘homestead’@’localhost’ (using password: YES),homestead这个用户哪来的。。
2015-09-19 16:57
我按教程运行到最后一步的时候
composer dump-autoload
php artisan db:seed
就报错了
[ReflectionException]
Class UserTableSeeder does not exist
请问是哪里的问题?
2015-09-18 15:14
<form action="{{ URL('admin/pages') }}" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="text" name="title" class="form-control" required="required">
<br>
<textarea name="body" rows="10" class="form-control" required="required"></textarea>
<br>
<button class="btn btn-lg btn-info">新增 Page</button>
</form>
这个action中并没有指明要调到pages中的哪个方法,为什么会进入store方法,laravel是怎么进行操作的?
2015-09-11 11:23
WenTableSeeder.php
class WenTableSeeder extends Seeder {
public function run()
{
DB::table('wens')->delete();
for ($i=0; $i < 10; $i++) {
Wen::create([
'title' => 'ArticlesTitle '.$i,
'slug' => 'first-article',
'author' => 'Lee '.$i,
'tag' => 'tag '.$i,
'body' => 'My is articles '.$i,
'user_id' => 2,
'image' => 'jpg '.$i,
]);
}
}
}
但是执行php artisan db:seed之后,总会提示这个错误:
Class 'Wen' not found
PHP Fatal error: Class 'Wen' not found in D:\phpStudy\WWW\test\firstpj\database\seeds\WenTableSeeder.php on line 12
不知道该怎处理
2015-09-09 17:57
我想要修改用户的栏位
CREATE TABLE IF NOT EXISTS `users` (
`users_id` int(10) unsigned NOT NULL,
`users_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`users_email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`users_tel` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`users_password` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
改了view 也改了Service\Registrar.php 但是还是出现错误
QueryException in Connection.php line 620:
SQLSTATE[HY000]: General error: 1364 Field 'users_name' doesn't have a default value (SQL: insert into `users` (`updated_at`, `created_at`) values (2015-09-09 09:17:41, 2015-09-09 09:17:41))
2015-09-09 18:30
2015-09-07 22:59
http://fuck.io:88 這頁可以出現
但到 http://fuck.io:88/home 則變成404 我不知道我哪做錯了請教教我
(v5.0.22)
2015-09-04 17:02
PagesController.php里面的public function edit只有
return view('admin.pages.edit')->withPage(Page::find($id));这一段代码,并没有看到分配的变量$page。
而且我把edit.blade.php里面的{{ $page->title }}改成{{ ¥pages->title }}后就会提示Undefined variable: pages
这个地方的变量名是在是么地方定义或分配的唷
2015-08-30 20:37
出现这个错误是为什么?我在网上搜索过,但也还是没有找到解决办法。
环境: Ubuntu 14.04
PHP 5.5.9
Apache 2.4.7
2015-08-27 17:55
- Installing laravel/laravel (v5.0.22)
Loading from cache
Created project in laravel
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16].
- laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
照旧啊。。。
2015-09-14 15:58
Installing laravel/laravel (v5.0.22)
- Installing laravel/laravel (v5.0.22)
Loading from cache
Created project in laravel
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16].
- laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
2015-08-27 17:29
- Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16].
- laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
mac下报这个错误,mcrypt在phpinfo可以看见的
2015-08-27 18:07
mcrypt support => enabled
mcrypt_filter support => enabled
Version => 2.5.8
Api No => 20021217
Supported ciphers => cast-128 gost rijndael-128 twofish arcfour cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes
Supported modes => cbc cfb ctr ecb ncfb nofb ofb stream
php-fpm -i查看的信息,没问题啊。
2015-09-05 13:46
cd ~
vim ./bash_profile
添加一行
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
保存退出
source .bash_profile
然后which php 看变化 ,现在安装应该没啥问 我今天刚遇到, laravel5新手!
2015-08-26 09:35
2015-08-25 00:36
2015-08-24 14:33
Installing laravel/laravel (v5.0.22)
- Installing laravel/laravel (v5.0.22)
Loading from cache
Created project in laravel
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for phpunit/phpunit 4.5.0 -> satisfiable by phpunit/phpunit[4.5.0].
- phpunit/phpunit 4.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
您好,请教一个问题 ,我在linux 安装报错 ,这个,有解决办法吗? 是加dom扩展 吗,但是加上了 没效果。
2015-08-24 16:56
yum install php-xml
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.btte.net
* remi-safe: mirrors.mediatemple.net
* updates: mirrors.yun-idc.com
Resolving Dependencies
--> Running transaction check
---> Package php-xml.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-46.el6_6 for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.24)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.22)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.13)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1()(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libexslt.so.0()(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Running transaction check
---> Package libxslt.x86_64 0:1.1.26-2.el6_3.1 will be installed
---> Package php-xml.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-46.el6_6 for package: php-xml-5.3.3-46.el6_6.x86_64
--> Finished Dependency Resolution
Error: Package: php-xml-5.3.3-46.el6_6.x86_64 (updates)
Requires: php-common(x86-64) = 5.3.3-46.el6_6
Installed: php-common-5.5.28-1.el6.remi.x86_64 (@remi-php55)
php-common(x86-64) = 5.5.28-1.el6.remi
Available: php-common-5.3.3-40.el6_6.x86_64 (base)
php-common(x86-64) = 5.3.3-40.el6_6
Available: php-common-5.3.3-46.el6_6.x86_64 (updates)
php-common(x86-64) = 5.3.3-46.el6_6
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
看的糊涂。
2015-08-23 21:31
php artisan make:model Page会创建在app/Http/Page.php model文件
在 ***_create_pages_table.php 中修改: //为什么会生成pages名的文件而不是 page
Schema::create('pages', function(Blueprint $table) //这里为什么不是page而是pages表
{
$table->increments('id');
$table->string('title');
$table->string('slug')->nullable();
$table->text('body')->nullable();
$table->integer('user_id');
$table->timestamps();
});
2015-08-20 11:32
D:\www\learnlaravel5.1>php artisan db:seed
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xD5\xC5\xC8\
xFD"' for column 'Name' at row 1 (SQL: insert into `students` (`NO`, `Name`
, `Class`, `Age`, `Birthday`, `updated_at`, `created_at`) values ("NO001",
"????", "一??", 20, 1980-01-09, 2015-08-20 03:18:38, 2015-08-20 03:18:38))
[PDOException]
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xD5\xC5\xC8\
xFD"' for column 'Name' at row 1
源码最后改成这样的:
class StudentTableSeeder extends Seeder{
public function run()
{
DB::table('students')->delete();
$NO = 'NO001';
$Name = '张三';
$Class = '一班';
$temp_date = '2015-01-09 19:25:43';
Student::create([
'NO' => '"'.$NO.'"',
'Name' => '"'.$Name.'"',
'Class' => '"'.$Class.'"',
'Age' => 20,
'Birthday' => date('Y-m-d',strtotime($temp_date))
]);
2015-08-15 14:09
分页的代码如下:
ArticlesController.php
public function index()
{
return view('articles.index')->withArticles(Article::paginate(2));
}
index.blade.php
<?php echo $articles->render(); ?>
生成的分页链接是这样的:http://localhost/articles/?page=4
这样还是显示第一页,
可是用这个地址:http://localhost/?page=4 就可以正常分页显示,
分页的代码都是一样的,我是新手,实在不知道该怎么弄了,请帮帮我吧
2015-08-22 14:03
2015-08-24 18:48
我后来发现是nginx的配置写错了,
location / {
try_files $uri $uri/ /index.php?$query_string;
}
这里不知道怎么回事写成:
location / {
try_files $uri $uri/ /index.php;
}
少了最后的?$query_string,所以url里的查询参数都丢掉了。
2015-09-11 17:39
我根据楼上那位同学的方法,在WenController.php里面:
public function index()
{
return view('wen')->withWens(Wen::paginate(15));
}
然后打开http://127.0.0.1/test/firstpj/public/wen?page=3发现可以实现分页跳转,
但是把<?php echo $wen->render(); ?>或者变换格式 {{ $wen->render() }}放到wen.blade.php里,打开网页就出现错误代码。
想请教下,如何能也页面下形成那种正常的翻页效果?麻烦了
2015-08-10 15:15
博主你好,为什么windows上总有这个问题?我php的版本是5.6.11
2015-08-09 12:41
请问“composer create-project laravel/laravel learnlaravel5 5.0.22”和“laravel new blog”有什么区别?
2015-08-06 17:03
2015-08-05 18:40
报错信息:Whoops, looks like something went wrong.
我自己测试过,用$page = new Page();是可以初始化的Page类的,所以这个我就不大清楚是什么原因导致的了。
2015-08-05 16:41
- Installing doctrine/inflector (v1.0.1)
Downloading: 60%
这儿,一直不往下走,请问如何处理。
2015-08-01 20:25
因为会自动转到auth的登录界面
可是我不知道邮箱账号和密码啊
博主你知道auth的默认账号密码是多少吗......
2015-07-29 11:04
个人目前理解的是: 访问 ....../public/home 实际相当于 ......./public/index.php/home , 将index.php后面的home作为参数传递到index.php文件中,而后,针对routes.php的配置找到home对应的controller类进行调用处理, 请问这样理解对吗?
2015-07-27 12:46
我只搭在了本地,为什么我通过 http://localhost/learnlaravel5/home/ 返回404,
通过 http://localhost/learnlaravel5/public/home 能去到 Auth,
看了 phpinfo(),已经开启了 rewrite_mod,http://localhost/learnlaravel5/public/,也能顺利的跳到跟您一样的页面。
2015-07-25 10:04
发现速度会有点卡,我测试首页,显示1000条记录的列表页,,要费时1.3秒,不查询数据库的页面还可以,在0.2秒这内。这个是什么问题,还是说框架都有这样的速度问题,请大神回复。
2015-07-23 13:56
运行php artisan migrate时候
Could not open input file: artisan
没找到解决方法, 那些命令是在cmd下运行嘛。。什么路径呢? 我这边到指定路径时会提示'' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
谢谢解答
2015-07-21 15:10
PDOException
SQLstate[hy000][2006]MySql server has gone away
请问这个要怎么解决呢?谢谢。。。
2015-07-21 12:43
是什么问题 可是在App目录下有Page.php
2015-07-21 14:36
2015-07-18 10:58
2015-07-18 00:47
我看您的代码中直接使用/css/xxx.css 就可以定向到public/css/xxx.css了这是怎样做到的呢?
如果我想使用一些类似常量的方法就像ThinkPHP中__URL__/public/css这样的引用地址又有那些常量或者替代方法呢?
多谢解答!
2015-07-14 10:30
再次请教一下:采用Composer-Setup.exe或命令行请求方式配置composer失败。所以我直接下载了composer.phar文件。本人电脑是win7系统,官网配置composer为系统全路径环境变量的指令我在win7命令行下试了无效。请问该将composer.phar如何配置?(ps:昨天试的只能在特定路径下运行 php composer.phar 才有效,直接composer无效,没有百度到直接下载composer.phar然后进行配置的具体操作)
谢谢指教!
2015-07-13 09:30
本人下载的是laravel5一键安装包版,现在要执行composer dump-autoload,但是预先没有下载过composer。laravelv-5.0.22\vendor文件夹中存在一个composer文件夹,是否是将该路径添加到path环境变量中?如果没有添加composer环境变量,则执行报错:'composer' 不是内部或外部命令,也不是可运行的程序或批处理文件。
谢谢指教!!!
2015-07-09 17:56
1、在http://localhost:8000/home输入邮箱和密码,界面跳转后出现SQLSTATE[HY000] [2002] ÓÉÓÚÄ¿±ê¼ÆËã»ú»ý¼«¾Ü¾ø£¬ÎÞ·¨Á¬½Ó¡£
2、win7 命令行输入 php artisan migrate出现:[PDOException] SQLSTATE[HY000] [2002] ????目???????????芫????薹????印?
请问是什么原因?
浏览器是unicode编码形式。
2015-07-09 18:07
具体界面如下:
Whoops, looks like something went wrong.
1/1 PDOException in Connector.php line 47: SQLSTATE[HY000] [2002] ÓÉÓÚÄ¿±ê¼ÆËã»ú»ý¼«¾Ü¾ø£¬ÎÞ·¨Á¬½Ó¡£
in Connector.php line 47
at PDO->__construct('mysql:host=localhost;dbname=homestead', 'homestead', 'secret', array('0', '2', '0', false, '0')) in Connector.php line 47
at Connector->createConnection('mysql:host=localhost;dbname=homestead', array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 20
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 58
at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 47
at ConnectionFactory->make(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false), 'mysql') in DatabaseManager.php line 177
at DatabaseManager->makeConnection('mysql') in DatabaseManager.php line 65
at DatabaseManager->connection() in PasswordResetServiceProvider.php line 63
at PasswordResetServiceProvider->Illuminate\Auth\Passwords\{closure}(object(Application), array()) in Container.php line 773
at Container->build(object(Closure), array()) in Container.php line 656
at Container->make('auth.password.tokens', array()) in Application.php line 613
at Application->make('auth.password.tokens') in Container.php line 1231
at Container->offsetGet('auth.password.tokens') in PasswordResetServiceProvider.php line 39
at PasswordResetServiceProvider->Illuminate\Auth\Passwords\{closure}(object(Application), array()) in Container.php line 773
at Container->build(object(Closure), array()) in Container.php line 656
at Container->make('auth.password', array()) in Application.php line 613
at Application->make('Illuminate\Contracts\Auth\PasswordBroker') in Container.php line 887
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 848
at Container->getDependencies(array(object(ReflectionParameter), object(ReflectionParameter)), array()) in Container.php line 813
at Container->build('App\Http\Controllers\Auth\PasswordController', array()) in Container.php line 656
at Container->make('App\Http\Controllers\Auth\PasswordController', array()) in Application.php line 613
at Application->make('App\Http\Controllers\Auth\PasswordController') in ControllerDispatcher.php line 83
at ControllerDispatcher->makeController('App\Http\Controllers\Auth\PasswordController') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Auth\PasswordController', 'getEmail') in Route.php line 198
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 131
at Route->run(object(Request)) in Router.php line 691
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Router.php line 693
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 660
at Router->dispatchToRoute(object(Request)) in Router.php line 618
at Router->dispatch(object(Request)) in Kernel.php line 210
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
at require_once('D:\xampp\xampproot\htdocs\laravel-v5.0.22\public\index.php') in server.php line 21
2015-07-09 11:12
直接访问:http://myservername/是可以出现首页的
2015-07-08 10:20
Composer could not find a composer.json file in C:\Users\MyPC\AppData
To initialize a project, please create a composer.json file as described in the
https://getcomposer.org/ "Getting Started" section
找不到composer.json这个文件是什么原因?
2015-07-07 15:47
Whoops, looks like something went wrong.
1/1 RuntimeException in compiled.php line 6608: No supported encrypter found. The cipher and / or key length are invalid.
2015-07-07 02:19
"然后将网站根目录配置为 learnlaravel5/public。
如果你不会配置,建议去学会配置,网上资料很多。如果自暴自弃,可以把 的第 29 行 'url' => 'http://localhost', 配置成你的子目录地址,注意,要一直配置到 ***/learnlaravel5/public。"
抱歉,我是web开发初学者,查了一晚上了还是没解决这个问题,请帮忙看看是什么原因,谢谢!
Define SRVROOT "F:/Apache24"
ServerRoot "${SRVROOT}"
LoadModule rewrite_module modules/mod_rewrite.so
DocumentRoot "F:/WWW/learnlaravel5/public"
<Directory "F:/WWW/learnlaravel5/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
这是我的httpd.conf配置(win7+apache2.4+php5.6),改完重启了,主页还是没转过来,依然显示的是F:/Apache24下的index.php , 请问是什么地方没设置对?
谢谢!
2015-06-18 17:07
我没有欢快的注册哈 一但注册就报错 我是新手 不太明白 他说的方法是指那个地方 麻烦您 指点一下 我用的是 5.1.2
Whoops, looks like something went wrong.
1/1
BadMethodCallException in compiled.php line 8714:
Method [validator] does not exist.
2015-06-14 23:22
我目前使用Phpstorm在学习Laravel,在写model create脚本的时候,下面的语句:
$table->string('slug')->nullable();
Phpstorm提示Illuminate\Support\Fluent不提供此方法“nullable()", 我看了下Fluent里确实没有定义。但是执行artisan migration又是成功的,而且数据库字段也定义了NULL。这是怎么一回事呢?
多谢解答
2015-06-13 15:20
请问是5.1版本去掉了自带的auth视图吗?
2015-06-10 15:29
2015-06-10 00:01
2015-06-05 22:38
2015-06-04 08:38
第一个:迁移数据的时候执行到php artisan fresh 这一步,然后发现migrations文件夹里的create文件都消失了,然后在想第二次执行php artision migrate的时候显示Nothing to migrate。现在无法第二次数据库迁移。。。
第二个:routes里添加auth以后访问首页显示找不到auth文件夹
2015-06-02 16:46
php artisan migrate 命令执行后提示一下错误
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
解决方法:
根目录下有个.env的文件打开后找
host=localhost 把这一段改成
host=127.0.0.1 才能顺利执行
2015-05-27 10:28
2015-05-21 22:26
2015-05-21 13:24
今天我在实验室用composer create-project laravel/laravel 安装的时候,一直抱错!之前一直好好的,而且现在宿舍电脑安装也没问题。。。一直无法解决。
cmd错误信息:
Generating autoload files
Could not open input file: artisan
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repos
itory-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--n
o-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs]
[package] [directory] [version]
2015-05-19 14:35
2015-05-17 09:31
2015-05-17 09:03
Fatal error: require(): Failed opening required 'F:\testphp\th-online\weixin\bootstrap/../vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in F:\testphp\th-online\weixin\bootstrap\autoload.php on line 17
2015-05-15 14:21
php artisan migrate打这个
出现了这个
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
然后怎么处理了 求帮忙谢谢
2015-05-13 21:59
1:用浏览器打开的时候没有任何错误提示,就是无法加载(服务器未发生数据)。
2:如果在public文件夹下直接写一个index.html替换掉index.php,能够访问到index.html。
3:storage的权限是777。
4:php的版本是PHP 5.5.9-1ubuntu4 (cli).
5:初始化的时候,composer没有提示错误
2015-05-14 10:06
// $compiledPath = __DIR__.'/../vendor/compiled.php';
// echo $compiledPath;
// if (file_exists($compiledPath))
// {
// require $compiledPath;
// }
2015-05-02 13:33
2015-04-17 11:47
再执行 php artisan migrate 就提示Noting to migrate !!怎么破
更惨的是我在数据库中drop 掉了 Page 表
2015-04-07 17:18
用 MongoDB 只需要修改一下配置文件。Ajax 跟 Laravel 本身没有什么特殊的联系。
2015-04-03 18:12
在 admin控制器中 use了一些公共资源,
如: use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Redirect, Input, Auth;
现在遇到的问题是,在menus控制器里面,如果没有加载如下两个资源
use Illuminate\Http\Request;
use Redirect, Input, Auth;
就会报错,加载上内容正确,是不是不能再admin控制器中use呢?
2015-04-02 19:28
Installing laravel/laravel (v5.0.22)
- Installing laravel/laravel (v5.0.22)
Loading from cache
Created project in learnlaravel5
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing jakub-onderka/php-console-color (0.1)
Downloading: 100%
Downloading: 100%
Downloading: 100%
Failed to download jakub-onderka/php-console-color from dist: The "https://a
pi.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4e
fc3df1435485197e6c1" file could not be downloaded: failed to open stream: 由于连
接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
Now trying to download from source
- Installing jakub-onderka/php-console-color (0.1)
Cloning e0b393dacf7703fc36a4efc3df1435485197e6c1
- Installing vlucas/phpdotenv (v1.1.0)
Downloading: Connecting...
大哥,你好,我是第一次玩composer,请问下,我己经用了中国镜像,还出这个错是什么原因呢.我连你教程的第一步都跑不了.麻烦解答下好么~~谢谢~~
2015-03-31 20:03
我是用软链接/var/www/demo指向/documents/demo/public下的
apache的document root是/var/www
2015-03-31 11:18
2015-03-30 17:57
老师,我用的超神的lavavel包,不能执行composer命令,错误原因:composer不是内部或外部.........
,有什么解决办法吗,谢谢了,好久了解决不了
2015-09-07 01:08
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Page' not found
2015-03-23 01:07
一直报这个错,请问怎么解决
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\xampp\htdocs\LearnLaravel5\bootstrap\app.php on line 14
2015-03-22 11:38
Generating autoload files
luoqianlideMacBook-Pro:blog qianli$ php artisan db:seed
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/Users/qianli/Web/blog/storage/logs/laravel-2015-03-22.log" could not be opened: failed to open stream: Permission denied' in /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84
Stack trace:
#0 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\Handler\StreamHandler->write(Array)
#1 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)
#2 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Logger.php(265): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#3 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Logger.php(543): Monolog\Logger->addRecord(400, 'exception 'Unex...', Array)
#4 /Users/qianli/Web/blog/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(47): Monolog\Logger->error('exception 'Unex...')
in /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 84
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/Users/qianli/Web/blog/storage/logs/laravel-2015-03-22.log" could not be opened: failed to open stream: Permission denied' in /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84
Stack trace:
#0 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\Handler\StreamHandler->write(Array)
#1 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)
#2 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Logger.php(265): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#3 /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Logger.php(543): Monolog\Logger->addRecord(400, 'exception 'Symf...', Array)
#4 /Users/qianli/Web/blog/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(47): Monolog\Logger->error('exception 'Symf...')
in /Users/qianli/Web/blog/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 84
luoqianlideMacBook-Pro:blog qianli$
请问做到这个教程,创建10个文章的时候,怎么报错呢
2015-03-19 22:25
C:\Users\Administrator\Desktop\blog>php artisan migrate
[PDOException]
Access denied for user 'root'@'localhost' (using password:YES)
我的.ENV文件如下:
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=laravel5
DB_USERNAME=root
DB_PASSWORD=password
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
2015-03-18 12:21
2015-03-17 12:49
2015-03-16 17:28
结果就出来个404,如果把AllowOverride 设置为All,就来一个:
NotFoundHttpException in compiled.php line 7693:
in compiled.php line 7693
at RouteCollection->match(object(Request)) in compiled.php line 6965
at Router->findRoute(object(Request)) in compiled.php line 6937
at Router->dispatchToRoute(object(Request)) in compiled.php line 6929
at Router->dispatch(object(Request)) in compiled.php line 1935
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 8952
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2438
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in compiled.php line 8944
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12083
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in compiled.php line 8944
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 10785
at StartSession->handle(object(Request), object(Closure)) in compiled.php line 8944
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11789
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in compiled.php line 8944
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11738
at EncryptCookies->handle(object(Request), object(Closure)) in compiled.php line 8944
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2478
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 8944
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 8935
at Pipeline->then(object(Closure)) in compiled.php line 1891
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 1880
at Kernel->handle(object(Request)) in index.php line 53
2015-03-16 09:12
```
Created project in Simpress
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing jakub-onderka/php-console-color (0.1)
Downloading: 100%
Downloading: 100%
Downloading: 100%
Failed to download jakub-onderka/php-console-color from dist: The "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Now trying to download from source
- Installing jakub-onderka/php-console-color (0.1)
Cloning e0b393dacf7703fc36a4efc3df1435485197e6c1
- Installing vlucas/phpdotenv (v1.1.0)
```
2015-03-12 22:33
D:\>cd www/
D:\www>cd learnlaravel5
D:\www\learnlaravel5>php artisan migrate
锘?*************************************
* Application In Production! *
**************************************
Do you really wish to run this command? [y/N] y
[PDOException]
SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'f
orge'
2015-03-11 10:33
错误提示:
There are no commands defined in the "db:" namespace.
Did you mean this?
2015-03-10 21:29
2018-10-24 04:12