Comments (4)
As far as I know, this is not possible. Corcel is connecting to WordPress through database, not API interface
from corcel.
To use WordPress plugins inside Laravel with Corcel, you can follow these steps:
-
Install Corcel: Start by installing the Corcel package in your Laravel project using Composer. Run the following command in your terminal:
composer require jgrossi/corcel
-
Configure the Database Connection: Configure the database connection in your Laravel project to connect to the WordPress database. Open the
config/database.php
file and add a new connection configuration for the WordPress database. Here's an example configuration:'wordpress' => [ 'driver' => 'mysql', 'host' => env('WP_DB_HOST', 'localhost'), 'database' => env('WP_DB_DATABASE', 'wordpress'), 'username' => env('WP_DB_USERNAME', 'root'), 'password' => env('WP_DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'wp_', ],
Make sure to update the
env
values to match your WordPress database credentials. -
Create Model Classes: Create model classes in your Laravel project that extend the Corcel models. These model classes will allow you to interact with the WordPress database tables. For example, you can create a
Post
model like this:<?php namespace App\Models; use Corcel\Model\Post as Corcel; class Post extends Corcel { protected $connection = 'wordpress'; protected $postType = 'post'; }
You can create additional model classes for other WordPress entities like
Page
,Category
,Tag
, etc. -
Use WordPress Plugins: Once you have set up the Corcel integration, you can use WordPress plugins in your Laravel project by leveraging the power of Corcel. You can interact with WordPress entities, such as posts, pages, categories, and tags, using the model classes you created. You can also access custom fields and metadata associated with WordPress entities.
Here's an example of fetching posts from WordPress using Corcel:
use App\Models\Post; $posts = Post::published()->take(5)->get(); foreach ($posts as $post) { echo $post->title; // Access other attributes or methods of the post model }
You can also use Eloquent relationships and query scopes with Corcel models to enhance your interactions with WordPress data.
By following these steps, you can effectively use WordPress plugins inside Laravel using Corcel. This integration allows you to leverage the functionality of WordPress while enjoying the development capabilities of Laravel.
from corcel.
Dead community?
from corcel.
So need just to somehow use WordPress api in Laravel
from corcel.
Related Issues (20)
- Trying to get property 'guid' of non-object.
- Corcel and Laravel Voyager incompatibility HOT 1
- How to use corcel in WordPress plugin for custom tables
- Get post category name HOT 1
- Multiple Database connection, What should I set connection in Corcel ? HOT 1
- Two factor authentification HOT 2
- Menu doesn't return Product Categories added to WordPress menus
- How to query for Posts with updated_at field ?
- Corcel acf plugin not installable
- Missing PhpOption\Option dependencies on CakePHP HOT 2
- DB connection error Laravel HOT 1
- Add support for Laravel 10 HOT 10
- onEachSide give error but works HOT 1
- Project abandoned? HOT 3
- The Eloquent model's deprecated $dates
- Laravel Nova & Corcel - many-to-many relation
- Getting error unserialize(): Error at offset 0 of 2 bytes - using Carbon Fields
- As A developer I want Documentation on how to upload, create, save and update Media to The Media Library So it's done it as intended HOT 2
- Laravel 11 and PHP 8.2 support HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corcel.