Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

WP Weekend #2 - Corcel, aneb WordPress přes Laravel

Martinova prezentace z 2. WP Weekendu konaného v píseckém technologickém centru 20.5.2017...

  • Sé el primero en comentar

WP Weekend #2 - Corcel, aneb WordPress přes Laravel

  1. 1. #wpweekendcz | @hlavacm
  2. 2. #wpweekendcz | @hlavacm
  3. 3. #wpweekendcz | @hlavacm
  4. 4. Composer? Bedrock, aneb WordPress přes Composer Brilo (Team) Blog: brilo.cz/bedrock-aneb-wordpress-pres-composer #wpweekendcz | @hlavacm
  5. 5. Téma a obsah 1. Laravel framework 2. Knihovna Corcel 3. WordPress demo #wpweekendcz | @hlavacm
  6. 6. 1. Laravel PHP MVC framework, který je optimalizovaný pro reálný svět https://laravel.com #wpweekendcz | @hlavacm
  7. 7. Laravel - služby Laravel & Lumen Homestead & Valet Laracasts & Laracon Cashier & Spark Forge & Envoyer a další ... #wpweekendcz | @hlavacm
  8. 8. Laravel 5.4 - požadavky ■ PHP >= 5.6.4 ■ OpenSSL PHP Extension ■ PDO PHP Extension ■ Mbstring PHP Extension ■ Tokenizer PHP Extension ■ XML PHP Extension #wpweekendcz | @hlavacm
  9. 9. Laravel - instalace $ composer global require "laravel/installer" $ laravel new blog $ composer create-project --prefer-dist "laravel/laravel" blog #wpweekendcz | @hlavacm
  10. 10. Laravel - konzole $ php artisan make:controller UserController --resource #wpweekendcz | @hlavacm
  11. 11. Laravel - kód <?php namespace AppHttpControllers; use AppUser; use AppHttpControllersController; class UserController extends Controller { public function show($id) { return view("user.profile", ["user" => User::findOrFail($id)]); } } #wpweekendcz | @hlavacm
  12. 12. Laravel - routování Route::get/post/put/patch/delete/options($uri, $callback); Route::get("user/{id}", function ($id) { return "User: $id"; }); Route::get("profile", "UserController@show")->middleware("auth"); Route::resource("users", "UserController"); #wpweekendcz | @hlavacm
  13. 13. Laravel - šablony <html> <head> <title>App Name - @yield("title")</title> </head> <body> @while (true) <p>I"m looping forever.</p> @endwhile <div class="container"> @yield("content") </div> </body> </html> #wpweekendcz | @hlavacm
  14. 14. Laravel - Eloquent (ORM) $users = AppUser::all(); foreach ($users as $user) { echo $user->display_name; } $users = AppUser::where("user_status", 1) ->orderBy("user_registered", "desc") ->take(10) ->get(); $user = AppUser::find(1); $user = AppUser::where("user_status", 0)->first(); #wpweekendcz | @hlavacm
  15. 15. 2. Corcel This package allows you to use WordPress as backend (admin panel) and retrieve its data using Eloquent, with any PHP project or even framework. https://github.com/corcel/corcel #wpweekendcz | @hlavacm
  16. 16. Corcel - instalace $ composer require jgrossi/corcel #wpweekendcz | @hlavacm
  17. 17. Corcel - konfigurace <?php // File: /config/database.php "connections" => [ "mysql" => [ … ], "wordpress" => [ "driver" => "mysql", "host" => "localhost", "database" => "corcel", "username" => "admin", "password" => "secret", "charset" => "utf8", "collation" => "utf8_unicode_ci", "prefix" => "wp_", "strict" => false, "engine" => null, ], ], #wpweekendcz | @hlavacm
  18. 18. Corcel - modely <?php // File: app/Post.php namespace App; use CorcelPost as Corcel; class Post extends Corcel { protected $connection = "wordpress"; } #wpweekendcz | @hlavacm
  19. 19. Corcel - volání // using the "wordpress" connection $posts = AppPost::all(); // using the "default" Laravel connection $posts = CorcelPost::all(); #wpweekendcz | @hlavacm
  20. 20. Corcel - posty // All published posts $posts = Post::published()->get(); $posts = Post::status("publish")->get(); // A specific post $post = Post::find(31); echo $post->post_title; // Filter by meta/custom field $posts = Post::published()->hasMeta("field")->get(); $posts = Post::hasMeta("acf")->get(); #wpweekendcz | @hlavacm
  21. 21. Corcel - save $post = new Post; $post->save(); $post = Post::find(1); $post->meta->username = "juniorgrossi"; $post->meta->url = "http://grossi.io"; $post->save(); #wpweekendcz | @hlavacm
  22. 22. Corcel - custom post type // using type() method $videos = Post::type("video")->status("publish")->get(); // using your own class class Video extends CorcelPost { protected $postType = "video"; } $videos = Video::status("publish")->get(); #wpweekendcz | @hlavacm
  23. 23. Corcel - uživatelé // only all categories and posts connected with it $cat = Taxonomy::where("taxonomy", "category") ->with("posts")->get(); $cat->each(function($category) { echo $category->name; }); // clean and simple all posts from a category $cat = Category::slug("uncategorized")->posts()->first(); $cat->posts->each(function($post) { echo $post->post_title; }); #wpweekendcz | @hlavacm
  24. 24. Corcel - uživatelé // All users $users = User::get(); // A specific user $user = User::find(1); echo $user->user_login; #wpweekendcz | @hlavacm
  25. 25. Corcel - co umí? ■ Posts ■ Advanced Custom Fields (ACF) ■ Custom Post Type ■ Shortcodes ■ Taxonomies ■ Post Format ■ Pages ■ Categories & Taxonomies ■ Attachment and Revision ■ Menu ■ Users ■ Authentication #wpweekendcz | @hlavacm
  26. 26. Corcel - kdekoliv? require __DIR__ . "/vendor/autoload.php"; $params = array( "database" => "database_name", "username" => "username", "password" => "pa$$word", "prefix" => "wp_" ); CorcelDatabase::connect($params); #wpweekendcz | @hlavacm
  27. 27. #wpweekendcz | @hlavacm
  28. 28. 3. Demo + #kimnaslidu #wpweekendcz | @hlavacm
  29. 29. Shrnutí Laravel + Corcel = ♥ #wpweekendcz | @hlavacm Front End Framework Knihovna
  30. 30. Využití Programátoři Front end Neumí vše ⚠ #wpweekendcz | @hlavacm

×