in most of the cases its a good idea to let the user confirm is password to prevent uneeded password support.
symfony2 has an own PasswordType in his formpackage.
Include the needed namespaces:
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
add the PassWordType to your form
Dieses Blog durchsuchen
Samstag, 16. Juli 2016
symfony 3) formating an emailfield
If you want to format your email textfield you can simply add the EmailType to the formbuilder. in your FormType
Just include the namespace before usage:
use Symfony\Component\Form\Extension\Core\Type\EmailType;
If you want some more configuration you can user the manual:
http://symfony.com/doc/current/reference/forms/types/email.html
All FieldType are found here:
http://symfony.com/doc/current/reference/forms/types.html
Just include the namespace before usage:
use Symfony\Component\Form\Extension\Core\Type\EmailType;
If you want some more configuration you can user the manual:
http://symfony.com/doc/current/reference/forms/types/email.html
All FieldType are found here:
http://symfony.com/doc/current/reference/forms/types.html
symfony 3 manyToOne Relation / foreignkeys in doctrine2
If you have multiple table related to one table, lets say via a userid you can tell symfony to do the job for you by generating enties for you.
You can also do this by yourself by editing the entities.
this is the database with all the many2one relations
At next we generate our entityclasses Posts, Replies and User
Have a look on the annotations of the userid in the related classes replies and post. In both cases the userid is tagged like that:
This annotation tells doctrine to relate the userid to the column "id" in the usertable
You can also do this by yourself by editing the entities.
this is the database with all the many2one relations
At next we generate our entityclasses Posts, Replies and User
Have a look on the annotations of the userid in the related classes replies and post. In both cases the userid is tagged like that:
This annotation tells doctrine to relate the userid to the column "id" in the usertable
mysql: add / editing a foreign key after database was created
This task is simple but offten needed.
If you have created a databasetable and you forgot the foreignkeys, you can simply add it later via altering table.
Add a foreignkey
This key references the userid from users to a tupel in table posts. If a user gets deleted or updated the post will be deleted to0.
Deleting a foreign key
asdasd
If you have created a databasetable and you forgot the foreignkeys, you can simply add it later via altering table.
Add a foreignkey
This key references the userid from users to a tupel in table posts. If a user gets deleted or updated the post will be deleted to0.
Deleting a foreign key
asdasd
Sonntag, 10. Juli 2016
Symfony 3.1 Add a encrypted passwordfield to your entity, controller and Form
If you have a passwordfield in your database you have to encrypt the passwordbefpre you can save it.
this task is pretty straight forward in symfony 3.1
Once you have created your entity (f. i BlogBundle\Entity\Users)
You have to implement the core security user interface to make the entity compatible to the encoder class. See my class to understand the mechanism:
Implement interfacemethods
You have to implement the last 2 methods (see class above) to fullfill the contract.
Modify security:
open app/config/security and add encoder like this:
clear cache after that
Add encoder to your user-controller
Add password and password confirmation field to your crud form
thats it
this task is pretty straight forward in symfony 3.1
Once you have created your entity (f. i BlogBundle\Entity\Users)
You have to implement the core security user interface to make the entity compatible to the encoder class. See my class to understand the mechanism:
Implement interfacemethods
You have to implement the last 2 methods (see class above) to fullfill the contract.
Modify security:
open app/config/security and add encoder like this:
clear cache after that
Add encoder to your user-controller
Add password and password confirmation field to your crud form
thats it
Install symphon2 on linux, create a project with database, crudforms and twittter bootstrap
Today we want to create a simple blogapplication with symfony (3.1)
LEVEL: PHP Advanced / Symfony2 Novice
This blog will have 3 features
- Users (add, delete, edit, login)
- Posts (add, delete, edit)
- Replies (add, delete, edit)
You need to have PHP 5 or 7 and Mysql Server running
Install Symfony
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/bin/local/symfony
Create App
php bin/console new blog 3.1
Create Bundle
php bin/console generate:bundle
- call it BlogBundle
Edit databaseconfiguration
open parameters.yml in config folder and edit databaseaccess
Create a database
php bin/console doctrine:database create
- call it blog
open a mysql client (fy mysql-workbench)
create needed tables
CREATE TABLE `replies` (
`id` int(11) NOT NULL,
`userid` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`firstname` varchar(255) DEFAULT NULL,
`lastame` varchar(255) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`isDeleted` tinyint(4) DEFAULT NULL, `isActive` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `blog`.`posts` (
`id` INT NOT NULL COMMENT '',
`userid` INT NULL COMMENT '',
`title` VARCHAR(255) NULL COMMENT '',
`content` TEXT NULL COMMENT '',
`isDeleted` TINYINT NULL COMMENT '', `isActive` TINYINT NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '');
create entities from database:
Add it to the
Optionally for the bootstrap theme, add this to your
LEVEL: PHP Advanced / Symfony2 Novice
This blog will have 3 features
- Users (add, delete, edit, login)
- Posts (add, delete, edit)
- Replies (add, delete, edit)
You need to have PHP 5 or 7 and Mysql Server running
Install Symfony
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/bin/local/symfony
Create App
php bin/console new blog 3.1
Create Bundle
php bin/console generate:bundle
- call it BlogBundle
Edit databaseconfiguration
open parameters.yml in config folder and edit databaseaccess
Create a database
php bin/console doctrine:database create
- call it blog
open a mysql client (fy mysql-workbench)
create needed tables
CREATE TABLE `replies` (
`id` int(11) NOT NULL,
`userid` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`firstname` varchar(255) DEFAULT NULL,
`lastame` varchar(255) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`isDeleted` tinyint(4) DEFAULT NULL, `isActive` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `blog`.`posts` (
`id` INT NOT NULL COMMENT '',
`userid` INT NULL COMMENT '',
`title` VARCHAR(255) NULL COMMENT '',
`content` TEXT NULL COMMENT '',
`isDeleted` TINYINT NULL COMMENT '', `isActive` TINYINT NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '');
create entities from database:
php bin/console doctrine:mapping:import --force BlogBundle xml
php bin/console doctrine:mapping:convert annotation ./src
php bin/console doctrine:generate:entities BlogBundle
Install twitter boodstrap crud bundle
composer require triton/crud-generator Add it to the
AppKernel.php class:new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(), new Triton\Bundle\CrudBundle\TritonCrudBundle(), Optionally for the bootstrap theme, add this to your
app/config/config.ymltwig:
form_themes:
- 'bootstrap_3_layout.html.twig'
generate crud controllers with twitter bootstrap look and feelphp bin/console triton:generate:crud
Samstag, 2. Juli 2016
Install magento via commandline on a linux machine
1) Install composer on your machine
at the moment you have to have installed php 7.0.2 minumumif you do not have a lamp stack installed, follow this very good guidehttps://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-16-04-lamp/
add a mysql user with needed rightsGRANT ALL on *.* to 'peter'@'localhost' identified by 'yoursecretpassword';
install needed php extensionsapt-get install php7.0-gd php7.0-xml php7.0-mcrypt php7.0-curl php7.0-intl php7.0-mbstring php7.0-zip php7.0-mysql
get composer follow https://getcomposer.org/download/ Create project with composer2)composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /var/www/html/magento2this downloads and installs magento2 under /var/www/magento2Username / Password repo.magnto.comduring the installation your are ask for username and password to repo.magento.orgYou have to create an account on https://marketplace.magento.com and create access keys.After you have created private and public key, you have to use the public key as username and the privatekey as the passwordmake cli executablecd /var/www/magento2 && chmod +x bin/magento
Database create a database named magento2
navigate to installdir cd /var/www/magento2set accessrights (all for the first time)chmod -R 777 * execute installcommand bin/magento setup:install --base-url=http://magento2.localhost/pub/ --language=en_US --backend-frontname=admin --db-host=localhost --db-name=magento2 --db-user=root --db-password=DBPASSWORD --admin-email=max@mustermann.de --admin-user=youradmin --admin-password=PASSWORD --admin-firstname=Max --admin-lastname=Mustermann
add sampledata and activate additional modulesbin/magento sampledata:deploy
bin/magento setup:upgrade
you will be asked for username and password again. user your pubkey as username and private key as password
bin/magento setup:upgrade
you will be asked for username and password again. user your pubkey as username and private key as password
enable devoloper-mode to see all php problems and get more information during runtimebin/magento deploy:mode:set developer
deploy static content, otherwise styles are missing
deploy static content, otherwise styles are missing
bin/magento setup:static-content:deploy add domain to your /etc/hostsnano etc/hosts127.0.0.1 magento2-shop.local add apache-vhost entry to your installationkeep sure, you link into the pubditectory, otherwise the css files arent found
this article is based on:http://alanstorm.com/magento-2-frontend-files-servingand https://www.integer-net.de/magento-2-installation/
Abonnieren
Posts (Atom)