eminos
eminos

Hello,

I've been a fan of Laravel for some time now, and I recently discovered OctoberCMS which seems just awesome!

I'm thinking about using OctoberCMS for some upcoming projects. A lot because of the strengths of Laravel that I really like, but also because of OctoberCMS.

So my question is how well does those two play together, and how do I use both when developing something in OctoberCMS? I know that OctoberCMS is using Laravel as the base. Does OctoberCMS change Laravel in some way? Some paths?

For example: Can I still use Laravels routes files to do URL routing? Am I able to use all of the composer packages for Laravel as usual? When developing something custom for a client, should I be doing it as a Laravel package or an OctoberCMS plugin?

Thanks.

/E

Flynsarmy
Flynsarmy

Can I still use Laravels routes files to do URL routing?

Create a plugin, create a routes.php file. As whatever you want.

Am I able to use all of the composer packages for Laravel as usual?

Depends on the package. Create a plugin and a composer.json, require the package in. Here's how you register a package's serviceprovider and alias in your plugin. October doesn't support asset publishing so you'll need to figure out a way around that.

When developing something custom for a client, should I be doing it as a Laravel package or an OctoberCMS plugin?

It's up to you, though october plugin would definitely make a lot more sense.

Last updated

eminos
eminos

Thank you Flynsarmy. I understand it better now, but I do have some follow up questions.

  1. So I have to require in components INTO my custom plugin. Can't I require in components into the "main installation and vendor folder" of October/Laravel, and that way skip pulling in an unnecessary extra Laravel installation into my plugin?

  2. What do you mean by "October doesn't support asset publishing"? This seems to be an issue (but I don't understand it).
Flynsarmy
Flynsarmy
  1. Correct. It kinda sucks but not much you can do about it. I guess you could require into october's vendor folder if you wanted. This would probably only work on composer intalls of October CMS and not installer installs and weird things could happen if it one day pulled in one of the packages you've already pulled in.

  2. My DebugBar plugin is a good example of this. Laravel Debugbar has a php artisan debugbar:publish command but it won't work in October because October doesn't use the 'app' folder.
eminos
eminos

Ok, I get it. Wouldn't both these problems be gone if we just require in the package into October's vendor folder? Or would it still not be possible to publish a component's assets and use them in October in a nice way?

I was kinda hoping October wouldn't interfere so much with Laravel and Laravel's workflow. But it seems it does.

Flynsarmy
Flynsarmy

You could try to require in but as I said above, the installer version of October doesn't even come with a composer.json in its root folder. When October updates itself, it drops files in there if need be. This could interfere with your composer installed version of October. I'm not sure as I've never attempted it before.

Agreed. I'd prefer October messed with the laravel workflow less too.

Keios
Keios

You can always push all business logic not related to october into a laravel package (best would be to create a composer package, then require it from laravel package and then require laravel package from october plugin) and then App::register it.

raheel
raheel

I'm trying to add Laravel Socialite to my October Instance with absolutely no luck. Mine is an install version of October means i don't have a composer.json file in root. Here's what i've done:

  1. Created a composer.json file in plugin directory with a require. i.e. "laravel/socialite": "~2.0"
  2. Ran Composer update which created a vendor folder and installed lot of packages including socialite
  3. Ran "Composer dump-autload"
  4. Added App::register('\Laravel\Socialite\SocialiteServiceProvider'); to my Plugin.php
  5. Added $alias = AliasLoader::getInstance(); $alias->alias('Socialize', 'Laravel\Socialite\Facades\Socialite'); to my Plugin.php

Now i get this error: http://pho.to/8mccb

Removing socialite from the require and doing composer update and unregistering the above Service Provider from Plugin.php file brings everything back to normal. 2 days are gone juggling with this... Appreciate any help.

Flynsarmy
Flynsarmy

The problem with using some packages is that when they require others in, those other packages may override octobers. For instance my DebugBar plugin included a copy of Laravel which override October's causing issues in some places.

I think to solve your problem you'll need to fork socialite and remove the dependencies.

raheel
raheel

Thanks Flynsarmy... I'll try to juggle a bit more with it... Was looking for a simple time saving solution, if this doesn't works for me, i'll have to use Facebook Auth APIs directly.

Appreciate your quick response.

Flynsarmy
Flynsarmy

I have an extensible Social Login plugin on the marketplace already incase you were interested :)

raheel
raheel

Thanks... I'll skip socialite and get your plugin.

FabioOliveiraCosta
FabioOliveiraCosta

I tryied to add a composer.json to the root of the project and OctoberCMS stopped working, probably messed with the autoloader. Sad that it interfere with the laravel workflow, i will see if i can get a workaround using composer parameters or something

vdomah
vdomah

Any luck with this question guys?

badigersumeet57083
badigersumeet57083

FabioOliveiraCosta said:

I tryied to add a composer.json to the root of the project and OctoberCMS stopped working, probably messed with the autoloader. Sad that it interfere with the laravel workflow, i will see if i can get a workaround using composer parameters or something

I did the same and it removed all october dependencies and delete modules directory

klas.wirholm
klas.wirholm

There is a routing in Rainlab Transle plugin. My bee you could just extend that translate class, after your needs.

1-16 of 16