$zip = new ZipArchive();
$res = $zip->open('file.zip');
if ($res) {
$zip->extractTo('unzip_dir/');
}
$zip->close();
phpinfo()でzipの項目がない場合は、zip拡張を読み込むことで使えるようになります。
$zip = new ZipArchive();
$res = $zip->open('file.zip');
if ($res) {
$zip->extractTo('unzip_dir/');
}
$zip->close();
// Usersテーブルから5000件のデータを抽出
$q = Doctrine_Query::create()
->from('User u')
->limit(5000)
->orderBy('u.id ASC')
->execute();
foreach ($q as $k => $val) {
$val->updated_at = date("Y-m-d H:i:s");
$val->save();
if ($k % 500 == 0){
printf("%d : %dKB\n", $k, (memory_get_usage(true) / 1024));
}
$val->free();
}
$q->free();
printf("End : %dKB\n", $k, (memory_get_usage(true) / 1024));
0 : 94976KB
500 : 99072KB
1000 : 102912KB
1500 : 106752KB
2000 : 111616KB
2500 : 115712KB
3000 : 119552KB
3500 : 123392KB
4000 : 127232KB
4500 : 131840KB
End : 137728KB
0 : 94976KB
500 : 95488KB
1000 : 95744KB
1500 : 96000KB
2000 : 97024KB
2500 : 97024KB
3000 : 97024KB
3500 : 97024KB
4000 : 97024KB
4500 : 97536KB
End : 99584KB
$ php artisan migrate:make profile
Created Migration: 2014_11_23_230533_profile
Generating optimized class loader
$ vim app/database/migrations/2014_11_23_230533_profile.php
public function up()
{
// profileテーブル作成
Schema::create('profile', function($table){
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
$ php artisan migrate
$ vim /app/models/Profile.php
class Profile extends Eloquent {
protected $table = 'profile';
protected $gurded = array('id');
protected $fillable = array('name');
}
$ vim /app/controllers/ProfileController.php
public function index()
{
$profile = new Profile;
$profile->name = 'jack';
$profile->save();
}
Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to undefined method Profile::save()"
Stacktrace:
#1 Symfony\Component\Debug\Exception\FatalErrorException in /app/controllers/ProfileController.php:15
#0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0
$ composer dump-autoload
Generating autoload files
$profile = new ProfileTable;
var_dump($profile);
object(Profile)#131 (1) { ["connection":protected]=> NULL }
$ vim vendor/composer/autoload_classmap.php
'Profile' => $baseDir . '/app/database/migrations/2014_11_23_230533_Profile.php',
$ vim /app/models/Profiles.php
<?php
class Profiles extends Eloquent {
protected $table = 'profile';
protected $gurded = array('id');
protected $fillable = array('name');
}
$ vim /app/controllers/ProfileController.php
$profile s = new Profiles;
$profiles->name = 'jack';
$profiles->save();
$ vim vendor/composer/autoload_classmap.php
'Profile' => $baseDir . '/app/database/migrations/2014_11_23_230533_Profile.php',
'Profiles' => $baseDir . '/app/models/Profiles.php',
+--+-------+----------------------------+----------------------------+
|id |name |created_at |updated_at |
+--+-------+----------------------------+----------------------------+
| 1 |jack |2014-11-24 00:42:36|2014-11-24 00:42:36|
+--+-------+----------------------------+----------------------------+
# sudo curl -sS https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /home/user/composer.phar
Use it: php composer.phar
インストール後のメッセージをみると、composerを使うには下記のようにしないとダメらしい。。# php composer.phar ~
これだと、不便だなと思いながらサイトを見直すと、オプションがちゃんと書いてありました!# sudo mv composer.phar /usr/local/bin/composer
これで、 composer コマンドが使えるようになったのでインストール終了です。# composer self-update
ローカル環境でKubernetesを使えるようにしようと環境構築中にエラーが 下記が今回のエラーで書き込みできない感じのメッセージが出ています。 $ brew install minikube Updating Homebrew... Error: The following ...