$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();
$ mkdir app/helpers
$ vim app/helpers/HelperDemo.php
<?php
function demo()
{
return "OK";
}
$ vim composer.json
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"files": [
"app/helpers/HelperDemo.php"
]
}
$ ssh -i .ssh/ssh.pem ec2-user@***.***.***.***
shell request failed on channel 0
$ ssh -i .ssh/ssh.pem ec2-user@***.***.***.***
Last login: Mon Feb 9 11:12:21 2015 from ***.ap.plala.or.jp
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2014.09-release-notes/
/bin/bash: Cannot allocate memory
Connection to ***.***.***.*** closed.
/bin/bash: Cannot allocate memory
<input type="file" id="decorate">
<div class="upload">
<p>UPLOAD</p>
</div>
$(document).ready(function(){
$('.upload').on('click', function(){
$('#decorate').trigger('click');
});
});
#decorate {
display: none;
}
.upload {
border: solid 1px #a3ffa3;
background-color: #b7ffb7;
width: 200px;
text-align: center;
border-radius: 10px;
}
#decorate {
visibility: hidden;
}
#decorate {
visibility: hidden;
height: 0px;
width: 0px;
}
$ vagrant box add ubuntu/trusty32 https://vagrantcloud.com/ubuntu/boxes/trusty32==> box: Loading metadata for box 'https://vagrantcloud.com/ubuntu/boxes/trusty32'==> box: Adding box 'ubuntu/trusty32' (v14.04) for provider: virtualbox box: Downloading: https://vagrantcloud.com/ubuntu/boxes/trusty32/versions/14.04/providers/virtualbox.box ==> box: Box download is resuming from prior download progress ==> box: Successfully added box 'ubuntu/trusty32' (v14.04) for 'virtualbox'! $ vagrant box list ubuntu/trusty32 (virtualbox, 14.04)
$ vagrant upBringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'ubuntu/trusty32'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'ubuntu/trusty32' is up to date... ==> default: Setting the name of the VM: virtual-env_default_1417616732058_47717 ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports...
default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => /Users/Development/virtual-env
$ vagrant ssh Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-40-generic i686) * Documentation: https://help.ubuntu.com/
System information as of Wed Dec 3 14:25:52 UTC 2014
System load: 0.83 Processes: 89 Usage of /: 2.6% of 39.34GB Users logged in: 0 Memory usage: 10% IP address for eth0: 10.0.2.15 Swap usage: 0%
Graph this data and manage this system at: https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud
0 packages can be updated. 0 updates are security updates.
vagrant@vagrant-ubuntu-trusty-32:~$
vagrant@vagrant-ubuntu-trusty-32:~$ exit logoutConnection to 127.0.0.1 closed.
$ vagrant halt ==> default: Attempting graceful shutdown of VM...
$ vagrant destroy default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
// 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|
+--+-------+----------------------------+----------------------------+
ローカル環境でKubernetesを使えるようにしようと環境構築中にエラーが 下記が今回のエラーで書き込みできない感じのメッセージが出ています。 $ brew install minikube Updating Homebrew... Error: The following ...