ini_set('display_errors', "On");
ini_set('error_reporting', E_ALL);
2019年2月14日木曜日
2019年1月24日木曜日
php DateTime diff
DateTime比較するには、diffを使います。
$datetime = new DateTime("20190101");
$today_dt = new DateTime();
// $datetimeと現在の日付を比較する、$datetime - $today_dt の感じ
$interval = $datetime->diff($today_dt);
どっちが後ろ(大きい)かは、$interval['invert']が1の場合、$datetimeのほうが大きい。
$datetime = new DateTime("20190101");
$today_dt = new DateTime();
// $datetimeと現在の日付を比較する、$datetime - $today_dt の感じ
$interval = $datetime->diff($today_dt);
どっちが後ろ(大きい)かは、$interval['invert']が1の場合、$datetimeのほうが大きい。
2019年1月19日土曜日
symfony Timestampable
1)StofDoctrineExtensionsBundleをインストール
composer require stof/doctrine-extensions-bundle
2)Activating Timestampable
config
stof_doctrine_extensions:
default_locale: ja_JP
orm:
default:
timestampable: true
3)Entityに以下追加
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
class User implements UserInterface
{
use TimestampableEntity;
......
4)bin/console make:migration
5)bin/console doctrine:migrations:migrate
2018年12月14日金曜日
css grid vs flex
Grid is Container-Based, Flexbox is Content-Based
This is an important difference. It shows that the flexbox layout is calculated after its content is loaded whereas the grid layout is calculated regardless of the content inside it. So, if possible, avoid using flexbox to build the overall layout of your website.
Grid Has a “Gap” Property, Flexbox Doesn’t
Flexbox is One Dimensional, Grid is Two Dimensional
Flexbox is best for arranging elements in either a single row, or a single column. Grid is best for arranging elements in multiple rows and columns.
Flexbox Wraps vs Grid Wraps
when a flex-item is wrapped and pushed in a new row, the Flexbox layout algorithm treats it as a part of a different flex-container. Hence the pushed item loses its context.
参考:https://www.webdesignerdepot.com/2018/09/grid-vs-flexbox-which-should-you-choose/
This is an important difference. It shows that the flexbox layout is calculated after its content is loaded whereas the grid layout is calculated regardless of the content inside it. So, if possible, avoid using flexbox to build the overall layout of your website.
Grid Has a “Gap” Property, Flexbox Doesn’t
Flexbox is One Dimensional, Grid is Two Dimensional
Flexbox is best for arranging elements in either a single row, or a single column. Grid is best for arranging elements in multiple rows and columns.
Flexbox Wraps vs Grid Wraps
when a flex-item is wrapped and pushed in a new row, the Flexbox layout algorithm treats it as a part of a different flex-container. Hence the pushed item loses its context.
参考:https://www.webdesignerdepot.com/2018/09/grid-vs-flexbox-which-should-you-choose/
2018年8月30日木曜日
frontend validation [native browser form validation]
[Required]
<input type="text" required>
[Length]
<input type="text" minlength="3" maxlength="12">
[Pattern]
<input type="password" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" required>
If you provide a title attribute with the pattern, the title value will be included with any error message if the pattern doesn't match.
[Number]
<input type="number" pattern="[-+]?[0-9]">
Browser support for input[type="number"] varies, but you can supply a pattern as a fallback.
<input type="number" step="any" pattern="[-+]?[0-9]*[.,]?[0-9]+">
You can allow floats (numbers with decimals) with the step attribute. This tells the browser what numeric interval to accept. It can be any numeric value (example, 0.1 ), or any if you want to allow any number.
You should also modify your pattern to allow decimals.
<input type="number" min="3" max="42" pattern="[3-9]|[1-3][0-9]|4[0-2]">
If the numbers should be between a set of values, the browser can validate those with the min and max attributes. You should also modify your pattern to match.
[Email]
<input type="email" pattern="^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$">
The email input type will alert users if the supplied email address is invalid. Like with the number input type, you should supply a pattern for browsers that don't support this input type.
[uri]
<input type="url" pattern="^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*)(?::\d{2,})?(?:[\/?#]\S*)?$">
[date]
<input type="date" pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))">
value is actually in this format: YYYY-MM-DD
type="time"
type="month"
You can style fields that have errors on them with the :invalid pseudo-selector, but you can't style the error messages themselves.
CSS tip: style invalid selectors only when they aren't currently being edited with :not(:focus):invalid { }
参考:https://css-tricks.com/form-validation-part-1-constraint-validation-html/
<input type="text" required>
[Length]
<input type="text" minlength="3" maxlength="12">
[Pattern]
<input type="password" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" required>
If you provide a title attribute with the pattern, the title value will be included with any error message if the pattern doesn't match.
[Number]
<input type="number" pattern="[-+]?[0-9]">
Browser support for input[type="number"] varies, but you can supply a pattern as a fallback.
<input type="number" step="any" pattern="[-+]?[0-9]*[.,]?[0-9]+">
You can allow floats (numbers with decimals) with the step attribute. This tells the browser what numeric interval to accept. It can be any numeric value (example, 0.1 ), or any if you want to allow any number.
You should also modify your pattern to allow decimals.
<input type="number" min="3" max="42" pattern="[3-9]|[1-3][0-9]|4[0-2]">
If the numbers should be between a set of values, the browser can validate those with the min and max attributes. You should also modify your pattern to match.
[Email]
<input type="email" pattern="^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$">
The email input type will alert users if the supplied email address is invalid. Like with the number input type, you should supply a pattern for browsers that don't support this input type.
[uri]
<input type="url" pattern="^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*)(?::\d{2,})?(?:[\/?#]\S*)?$">
[date]
<input type="date" pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))">
value is actually in this format: YYYY-MM-DD
type="time"
type="month"
You can style fields that have errors on them with the :invalid pseudo-selector, but you can't style the error messages themselves.
CSS tip: style invalid selectors only when they aren't currently being edited with :not(:focus):invalid { }
参考:https://css-tricks.com/form-validation-part-1-constraint-validation-html/
2018年8月29日水曜日
2018年6月19日火曜日
gitの使い方
git help config
git config --list --show-origingit config --global user.name "<Your Name>"
git config --global user.email "<Your Email>"
# makes sure that Git output is colored
git config --global color.ui auto
# displays the original state in a conflict
git config --global merge.conflictstyle diff3
git init
or git clone https://github.com/project-name your-project-name
git status
git log
git log --oneline
git log --stat
git log -p
#ignore white space
git log -w
git show fdf5493
we have some new files that we want Git to start tracking
for Git to track a file, it needs to be committed to the repository
for a file to be committed, it needs to be in the Staging Index
the git add command is used to move files from the Working Directory to the Staging Index
git add
move files from the Working Directory to the Staging Index
move modified files to the Staging Index
The goal is that each commit has a single focus. Each commit should record a single-unit change. Each commit should make a change to just one aspect of the project. Conversely, a commit shouldn't include unrelated changes
git diff
The git diff command can be used to see changes that have been made but haven't been committed, yet.
.gitignore
Globbing lets you use special characters to match patterns/characters. In the .gitignore file, you can use the following:
blank lines can be used for spacing
# - marks line as a comment
* - matches 0 or more characters
? - matches 1 character
[abc] - matches a, b, or c
** - matches nested directories - a/**/z matches
a/z
a/b/z
a/b/c/z
If you make a merge on the wrong branch, use this command to undo the merge:
git reset --hard HEAD^
When a merge happens, Git will:
1)look at the branches that it's going to merge
2)look back along the branch's history to find a single commit that both branches have in their commit history
3)combine the lines of code that were changed on the separate branches together
4)makes a commit to record the merge
When we merge, we're merging some other branch into the current (checked-out) branch. We're not merging two branches into a new branch. We're not merging the current branch into the other branch.
Git tracks lines in files. A merge conflict will happen when the exact same line(s) are changed in separate branches.
git commit --amend
git revert <SHA-of-commit-to-revert>
branchを作成
git branch <branchname>
branchを確認
git branch
branchを切り替え
git checkout <branchname>
branchを削除
git branch -d <branchname>
Merge
git merge <branchname>
fetchを実行すると、リモートリポジトリの最新の履歴の取得だけを行うことができます。取得したコミットは、名前の無いブランチとして取り込まれます。このブランチはFETCH_HEADという名前でチェックアウトすることができます。
ローカルリポジトリからリモートリポジトリにpushするときは、pushしたブランチがfast-forwardマージされるようにしておく必要があります。もし、競合が発生するような場合は、pushが拒否されます。
登録:
投稿 (Atom)